0

我有大量要编入索引的新闻文章。我想避免索引很多几乎相同的文章(例如,来自新闻服务的文章可能多次出现,日期格式略有不同)。

所以我想我会为每篇文章做一个更像这样的查询。如果我得到一个分数 > 一些截止值的命中,那么我认为这篇文章已经被索引了,我不理会它。

但是,当我运行更像这样的查询时,我得到的所有命中都以零分返回。我不知道这是否是预期的,如果我做错了什么,或者我是否发现了一个错误。

我的查询看起来像:

POST _search
{"query": 
  {"bool": 
    {"filter": [
      {"more_like_this": 
        {"fields": ["text"], 
         "like": "Doctor Sentenced In $3.1M Health Care Fraud Scheme  Justice Department Documents & Publications \nGreenbelt, Maryland - U.S. District Judge Deborah K. Chasanow sentenced physician [snip]"
        }
      }
    ]
  }
}

我得到的结果是:

{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 390,
    "max_score": 0,
    "hits": [
      [snip]
4

3 回答 3

1

原因是您的 MLT 查询位于过滤器查询中。过滤器查询总是返回零分。将您的 MLT 放在必须或应该查询中,您将获得分数。

于 2017-01-11T16:51:41.927 回答
0

您得到零分,因为 Bool 运算符的过滤器部分不包括在分数的计算中。它仅用于过滤结果。您应该使用 MUST 运算符来获得分数。

POST _search
{"query": 
  {"bool": 
    {"must": [
      {"more_like_this": 
        {"fields": ["text"], 
         "like": "Doctor Sentenced In $3.1M Health Care Fraud Scheme  Justice Department Documents & Publications \nGreenbelt, Maryland - U.S. District Judge Deborah K. Chasanow sentenced physician [snip]"
        }
      }
    ]
  }
}

有关更多信息,请参阅文档 https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

于 2017-08-10T08:14:30.013 回答
0

我今天遇到了类似的问题,more_like_this 查询没有返回结果给我。因为我使用的是非默认路由而不是通过_routing.

我的查询如下所示,我必须articledefault_11文档字段keywordscontents.

GET localhost:9200/alias_default/articles/_search
{
                "more_like_this": {
                    "fields": [
                        "keywords",
                        "contents"
                    ],
                    "like": {
                        "_index": "default_11",
                        "_type": "articles",
                        "_routing": "6",
                        "_id": "1000000000006000000000000000014"
                    },
                    "min_word_length": 2,
                    "min_term_freq": 2
                }
  }

还要记住传递_routing参数。

This issue typically occurs when documents are indexed with non-default routing

请参阅:ElasticSearch 在搜索中返回文档但在 GET 中不返回

于 2016-05-06T14:03:38.740 回答