2015-05-13 73 views
0

我抓我的頭在以下Elasticsearch問題:爲什麼_explain返回的文檔匹配:true不會被_search返回?

GET /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不會返回 文件?

+2

您的查詢匹配了多少個總結果?由於您沒有指定'from/size',因此默認情況下會返回前10個結果。也許文件10007比這更晚。 – Val

+0

這是我的第一個想法 - 它目前匹配11個結果,但是,增加「大小」並不會改變任何東西 – glittershark

+0

實際上劃傷 - 結果體中的「命中」是11,但只有11箇中的前10個存在。 @Val發佈,作爲答案,我可以接受它! – glittershark

回答

1

您的查詢匹配多少個總結果?由於您沒有從/ size中指定,因此默認值是返回前10個結果。也許文件10007比這更晚。

相關問題