Elasticsearch---学习记录(3)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/D_iRe_Wol_F/article/details/83150738

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,有空继续研究.

猜你喜欢

转载自blog.csdn.net/D_iRe_Wol_F/article/details/83150738