繁体   English   中英

在 Elasticsearch 中重建索引时如何忽略丢失的字段

[英]How ignore missing fields while reindexing in Elasticsearch

如果我有一个只有部分源索引的目标索引,并且我只想将这些字段从源索引重新索引到目标索引,我是否仍可以使用重新索引 API 或者我应该如何处理这种情况? 任何解决方案或建议谢谢!

您还可以考虑excludes选项以排除不需要的字段:

curl -X POST "localhost:9200/_reindex?pretty" -H 'Content-Type: application/json' -d'
{
  "source": {
    "index": "source-index",
    "_source": {
      "excludes": ["exclude_a", "exclude_b"]
    }
  },
  "dest": {
    "index": "dest-index"
  }
}
'

重新索引时,您可以应用许多操作,例如重命名字段、仅重新索引与查询匹配的文档,或者 - 这就是您正在寻找的 - 仅重新索引特定字段。

POST _reindex
{
  "source": {
    "index": "old_index_name",
    "_source": ["field-a", "field-b", "other_field"]
  },
  "dest": {
    "index": "target_index_name"
  }
}

这是此处讨论的功能的文档: https : //www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-filter-source

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM