重新索引弹性搜索不会 return 所有文档

reindexing elastic search does not return all documents

我的弹性搜索中有大约 150 万个文档。我希望重新索引它们,以便每个索引过滤包含某些关键字的文档,以及一个 (null index) 不包含我在其他索引中指定的任何关键字的文档。我不确定为什么我的索引返回的文档比预期的少。特别是我预计 120 万份文件在 null index 但它在新索引中只返回了大约 30k 个文档。将不胜感激关于我在这里做错了什么的想法!

这就是我重新索引在多个字段中包含某些关键字的文档的方式

curl --location --request POST 'http://abcdef2344:9200/_reindex' \
--header 'Content-Type: application/json' \
--data-raw '{
  "source": {
    "index": "mydocs_email_*",
    "query": {
      "bool": {
        "filter": [
          {
            "bool": {
              "should": [
                {
                  "multi_match": {
                    "fields": [
                      "content",
                      "meta.raw.Message:Raw-Header:Subject"
                    ],
                    "query": "keyword1"
                  }
                },
                {
                  "multi_match": {
                    "fields": [
                      "content",
                      "meta.raw.Message:Raw-Header:Subject"
                    ],
                    "query": "keyword2"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  },
  "dest": {
    "index": "analysis_keywords"
  }
}'

然后我使用must_not创建另一个不包含keyword1keyword2的索引。

curl --location --request POST 'http://abcdef2344:9200/_reindex' \
--header 'Content-Type: application/json' \
--data-raw '{
  "source": {
    "index": "mydocs_email_*",
    "query": {
      "bool": {
        "filter": [
          {
            "bool": {
              "must_not": [
                {
                  "multi_match": {
                    "fields": [
                      "content",
                      "meta.raw.Message:Raw-Header:Subject"
                    ],
                    "query": "keyword1"
                  }
                },
                {
                  "multi_match": {
                    "fields": [
                      "content",
                      "meta.raw.Message:Raw-Header:Subject"
                    ],
                    "query": "keyword2"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  },
  "dest": {
    "index": "analysis_null"
  }
}'

null index 返回了 29.7k 个文档。从错误消息看来,我应该期望有 128 万个文件。它还说我需要增加索引中的字段数量 - 我也在 运行 上面的代码之后做了。虽然文件数量仍然保持不变。

{"took":53251,"timed_out":false,"total":1277428,"updated":243,"created":29755,"deleted":0,"batches":30,"version_conflicts":0,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[{"index":"analysis_null","type":"_doc","id":"/email/.......msg","cause":{"type":"illegal_argument_exception","reason":"Limit of total fields [1000] in index [analysis_null] has been exceeded"},"status":400}]

该错误的意思与它所说的完全一致 -- 在重建索引期间超出了字段总数的硬性限制。

在 重建索引之前 更改该设置不能解决问题吗?

DELETE analysis_null

PUT analysis_null
{
  "settings": {
    "index.mapping.total_fields.limit": 10000
  }
}