Elasticsearch---學習記錄(3)
阿新 • • 發佈:2018-11-24
14.記錄------_all欄位和date欄位查詢
官文上介紹了_all查詢和date欄位查詢的不同,自己實踐進行了解.
首先head顯示,兩個索引的結果顯示.
例項查詢
引數:_search?q=2018
curl -XGET http://172.16.150.149:29200/twitter,facebook/_search?q=2018 {"took":1,"timed_out":false,"_shards": {"total":4,"successful":4,"failed":0}, "hits": {"total":6,"max_score":0.4375,"hits": [{"_index":"twitter","_type":"big","_id":"777","_score":0.4375,"_source":{"title":"bigweb","text":"nothing","d":"2018/10/18"}}, {"_index":"twitter","_type":"blog","_id":"777","_score":0.4375,"_source":{"title":"bigweb","text":"nothing","d":"2018/10/18"}}, ...
直接用q=2018
是屬於_all欄位
查詢(參考官文)
hits-totle:6
顯示完全.
引數:_search?q=date:2018
curl -XGET http://172.16.150.149:29200/twitter,facebook/_search?q=date:2018 {"took":1,"timed_out":false,"_shards":{"total":4,"successful":4,"failed":0},"hits":{"total":4,"max_score":0.625,"hits": [{"_index":"facebook","_type":"blog","_id":"AWZ67I_dHFL4sAFl7IMJ","_score":0.625,"_source":{"title":"website","text":"blog is making","date":"2018/1016"}}, {"_index":"facebook","_type":"blog","_id":"pretty","_score":0.37158427,"_source":{"title":"website","text":"blog is making","date":"2018/1016"}}, ...
hits-totle:4
顯示部分.
開始以為date
引數問題,重新測試_search?q=d:2018
(因為也存在d
欄位)
curl -XGET http://172.16.150.149:29200/twitter,facebook/_search?q=d:2018
{"took":1,"timed_out":false,"_shards":{"total":4,"successful":4,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
hits-totle:4
且沒有顯示詳情了.
看來這個引數不是預設查詢的欄位. 資料
如果輸入新的欄位型別就動態對映猜測欄位型別.
es的搜尋邏輯是分析再inverse index,有空繼續研究.