首页 > 解决方案 > ElasticSearch more_like_this - 选项是在源索引还是目标索引上运行?

问题描述

more_like_this 函数的一个有用特性是 ES 是交叉搜索不同索引的能力,假设字段名称和映射对应。

让我感到困惑的一件事是如何在这些情况下应用术语选择参数。

考虑:

max_doc_freq

从输入文档中忽略术语的最大文档频率。这对于忽略诸如停用词之类的高频词很有用。默认为无界(Integer.MAX_VALUE,即 2^31-1 或 2147483647)。

这是源文档索引上的文档频率吗?还是会应用于我们正在查询的索引?

例子:

GET index_a/_search
{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "should": [
            {
              "more_like_this": {
                "boost": 1,
                "fields": [
                  "text"
                ],
                "include": true,
                "like": [
                  {
                    "_id": "tI2N_24BFVRF37fDxSTT",
                    "_index": "index_b"
                  }
                ],
                "max_doc_freq": 50000,
                "max_query_terms": 50,
                "min_term_freq": 1,
                "min_word_length": 4,
                "minimum_should_match": "1%",
                "stop_words": []
              }
            }
          ]
        }
      },
      "script_score": {
        "script": "1.0"
      }
    }
  }
}

在这种情况下,max doc freq 设置为 50,000。但这是在 index_a 上吗?还是 index_b?

标签: elasticsearchelasticsearch-query

解决方案


那是在重写查询短语中考虑的。所以index_b。重写阶段将MLT 重写为布尔查询


推荐阅读