Kibana 如何在已索引的文档上使用摄取管道?

aoyhnmkz  于 2023-05-15  发布在  Kibana
关注(0)|答案(3)|浏览(254)

我一直在使用FOSElasticaBundle将我的文档(通过Doctrine保存在数据库中的Symfony项目的实体)索引到Elastic Search中。FOSElastica在所有文档之后进行自动Map和索引。
问题是,我想对每个文档应用一些操作(对那些已经索引的文档和那些将要索引的文档),所以管道和无痛似乎是一个很好的解决方案。
但是,我不能理解如何将管道应用于已经索引的文档,你知道如何吗?
我已经看到你可以在ES请求后添加一个“pipeline=my_pipeline_name”,但是你可以对单个文档这样做,而我希望它影响所有文档。

sulc1iza

sulc1iza1#

您可以在将数据从 * 一个索引 * 移动到 * 另一个索引 * 时使用Pipeline
您需要使用Reindex API,以便在从一个索引到另一个索引的movement/ingestion_process期间对数据执行它。

注意:这是 * 索引级操作 *,意味着会影响所有文档。
以下是步骤摘要:

  • 创建一个temporary_index
  • source_indextemporary_index的重索引利用了Reindex API。还包括管道(下面提供了示例查询)
  • 删除并重新创建source_index。确保在创建索引时也包括Map。
  • 使用source_index作为目标名称,temporary_index作为源名称***执行相同的查询,但不使用管道***

下面是如何使用Reindex API与管道

POST _reindex
{
  "source": {
    "index": "source_index_name"
  },
  "dest": {
    "index": "temporary_index",
    "pipeline": "some_ingest_pipeline"
  }
}

让我知道如果这有帮助!

zwghvu4y

zwghvu4y2#

所以,过了一段时间,我找到了一个更有效的解决方案:Dynamic templatesIndex templates
实际上,我在ElasticSearch无法识别某些类型的字段(如date或geo_point)时遇到了麻烦,所以我在模板的帮助下将它们强制用于专门命名的字段。
如果你想要我在FOSElastica(doc is here)中的配置示例:

fos_elastica:
    serializer: 
        serializer: jms_serializer
    clients:
        default: 
            host: localhost 
            port: 9200
    index_templates: # https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-templates.html
        base_template: # this is a custom name for the index template
            client: default
            template: "*" # this is where you define which indices will use this template
            types:
                _doc: # this is where you define which types will use this (_doc stands for every type/documents)
                    dynamic_templates: # https://www.elastic.co/guide/en/elasticsearch/reference/6.8/dynamic-templates.html
                        dynamic_date_template: # this is a custom name for the dynamic field template
                            match_pattern: regex
                            match: created|updated|tpq_date|taq_date
                            mapping:
                                type: date
                        dynamic_location_template:
                            match: location
                            mapping:
                                type: geo_point
ie3xauqp

ie3xauqp3#

我有类似的问题,我得到的数据(经度和纬度)作为两个不同的领域,我想俱乐部到类型geo_point的单一领域。不确定我是否可以使用dynamic_templates,因此我可以将两个字段(经度和纬度)的值club/ concat到一个名为location的字段中,并将该类型定义为geo_point。

相关问题