elasticsearch,kibana,foselasticabundle,Php,elasticsearch,Kibana,Foselasticabundle" /> elasticsearch,kibana,foselasticabundle,Php,elasticsearch,Kibana,Foselasticabundle" />

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

Php 如何在已编制索引的文档上使用摄取管道?,php,elasticsearch,kibana,foselasticabundle,Php,elasticsearch,Kibana,Foselasticabundle,我一直在使用FOSElasticaBundle将我的文档(这些文档来自通过条令保存在db中的Symfony项目的实体)索引到弹性搜索中。FOSElastica会自动映射和索引所有文档 问题是,我想在每个文档上应用一些操作(在已经索引的文档和以后的文档上),所以管道和无痛似乎是一个很好的解决方案 但是,我无法理解如何将管道应用于已编制索引的文档,您知道如何吗 我已经看到,您可以在ES请求后添加“pipeline=my_pipeline_name”,但您可以为单个文档添加“pipeline=my_p

我一直在使用FOSElasticaBundle将我的文档(这些文档来自通过条令保存在db中的Symfony项目的实体)索引到弹性搜索中。FOSElastica会自动映射和索引所有文档

问题是,我想在每个文档上应用一些操作(在已经索引的文档和以后的文档上),所以管道和无痛似乎是一个很好的解决方案

但是,我无法理解如何将管道应用于已编制索引的文档,您知道如何吗

我已经看到,您可以在ES请求后添加“pipeline=my_pipeline_name”,但您可以为单个文档添加“pipeline=my_pipeline_name”,而我希望它影响所有文档。

您可以在将数据从一个索引移动到另一个索引时使用

您需要使用,以便在数据从一个索引移动到另一个索引的过程中对其执行
移动/摄取\u过程

注意:这是索引级操作,意味着它将影响所有文档

以下是步骤摘要:

  • 创建一个
    临时索引
  • 源索引
    重新索引到
    临时索引
    使用。还包括管道(下面提供的示例查询)
  • 删除并重新创建
    源索引
    。确保在创建索引时也包含映射
  • 使用
    源索引
    作为目标名称和
    临时索引
    作为源名称执行相同的查询,而不使用管道
下面是如何将Reindex API与管道一起使用

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

让我知道这是否有帮助

所以,过了一段时间,我找到了一种更有效的解决问题的方法:和

事实上,ElasticSearch无法识别某些类型的字段(如date或geo_point),因此我在模板的帮助下强制将它们用于特定命名的字段

如果您想要我在FOSElastica()中的配置示例:


另请注意,如果您的索引太大,并且希望看到重新索引操作的状态,而它仍在后台处理,请参阅
任务API
,这将帮助您提供重新索引操作期间处理了多少文档以及还剩下多少文档的信息。看看这个:可能会有帮助
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