为什么_explain返回匹配的文档:_search不返回true?

时间:2015-05-13 20:45:02

标签: elasticsearch

我对以下Elasticsearch问题感到头疼:

使用以下正文获取/myindex/mytype/_search

{
  "query": {
    "bool": {
      "should": [
        {
          "prefix": {
            "name": "attorneys"
          }
        },
        {
          "multi_match": {
            "query": "attorneys",
            "type": "most_fields",
            "fields": [
              "name^2",
              "description"
            ]
          }
        },
        {
          "nested": {
            "boost": 2.0,
            "path": "categories",
            "score_mode": "sum",
            "query": {
              "bool": {
                "should": [
                  {
                    "match": {
                      "categories.name": {
                        "fuzziness": 10,
                        "query": "attorneys"
                      }
                    }
                  },
                  {
                    "term": {
                      "categories.name": "attorneys"
                    }
                  }
                ]
// ...closing brackets trimmed for conciseness

不会返回ID = 10007的文档。

但是,具有完全相同查询体的GET /myindex/mytype/10007/_explain将返回:

{
  "_index": "vendors",
  "_type": "vendor",
  "_id": "10007",
  "matched": true,
  "explanation": {
    "value": 0.26991397,
    "description": "product of:",
    "details": [
      {
        "value": 0.8097419,
        "description": "sum of:",
        "details": [
          {
            "value": 0.8097419,
            "description": "Score based on child doc range from 304 to 304"
          }
        ]
      },
      {
        "value": 0.33333334,
        "description": "coord(1/3)"
      }
    ]
  }
}

为什么_explain会返回"matched": true,但_query不会返回exec 文件?

1 个答案:

答案 0 :(得分:1)

您的查询匹配的总结果数是多少?由于未指定from / size,因此默认为返回前10个结果。也许文件10007晚于此。