2014-07-17 20 views
0

繼倒胃口 '命中' 是如何elasticsearch響應

curl -X POST "http://localhost:9200/articles/_search?pretty=true" -d ' { "facets": { "speaker" : { "terms" : {"field" : "speaker"} } } }'

樣本響應

{ 
"took": 16, 
"timed_out": false, 
"_shards": { 
    "total": 5, 
    "successful": 5, 
    "failed": 0 
}, 
"hits": { 
    "total": 111396, 
    "max_score": 1, 
    "hits": [ 
     { 
      "_index": "shakespeare", 
      "_type": "line", 
      "_id": "63098", 
      "_score": 1, 
      "_source": { 
       "line_id": 63099, 
       "play_name": "Merchant of Venice", 
       "speech_number": 5, 
       "line_number": "3.3.14", 
       "speaker": "SHYLOCK", 
       "text_entry": "Ill have my bond; and therefore speak no more." 
      } 
     }, 
     { 
      "_index": "shakespeare", 
      "_type": "line", 
      "_id": "63101", 
      "_score": 1, 
      "_source": { 
       "line_id": 63102, 
       "play_name": "Merchant of Venice", 
       "speech_number": 5, 
       "line_number": "3.3.17", 
       "speaker": "SHYLOCK", 
       "text_entry": "To Christian intercessors. Follow not;" 
      } 
     } 

    ] 
}, 
"facets": { 
    "speaker": { 
     "_type": "terms", 
     "missing": 0, 
     "total": 111396, 
     "other": 100157, 
     "terms": [ 
      { 
       "term": "GLOUCESTER", 
       "count": 1920 
      }, 
      { 
       "term": "HAMLET", 
       "count": 1582 
      } 
     ] 
    } 
} 

}

有人可以解釋這擊中響應的一部分樣本響應。

  • 爲什麼hits.hits是一個數組?
  • 每個命中對象的含義是什麼?
  • 有沒有辦法從彈性搜索響應中抑制命中?
+1

爲什麼downvote?注意:方面被聚合所取代:'Elasticsearch 1.0中的方面已被聚合所取代,這些方面是方面的超集。「我希望聚集的結果沒有發生結果,我認爲這就是Venkat問題的精神。即使Elasticsearch以任何方式執行相同的工作,空的匹配數組也會使響應變得更小。 –

+0

@TheRedPea你說得對。 –

回答

3
  • hits.hits是滿足搜索查詢
  • 每個對象都代表一個發現的文件中發現的文件的陣列 - 你可以在這裏看到它的ID,類型和屬性裏面_source對象
  • 可以指定"size" : 0條款在您的搜索查詢然後hits.hits陣列將爲空