hits

elasticsearh搜索过滤filter

喜你入骨 提交于 2019-12-07 02:29:22
首先要讲下,为什么需要使用filter过滤 过滤并不会返回一个匹配度score,以至于它比查询要快很多 过滤查询后的结果能被缓存到内存中,并被多次重复使用. 1.如果我们要查询出account中blance从20000到30000之间的数据 curl -XPOST localhost:9200/bank/_search?pretty -d '{ "query":{ "filtered":{ "query":{ "match_all":{}}, "filter":{ "range":{ "balance":{ "gte":20000, "lte":30000 } } } } } }' { "took" : 102, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 217, "max_score" : 1.0, "hits" : [ { "_index" : "bank", "_type" : "account", "_id" : "49", "_score" : 1.0, "_source":{"account_number":49,"balance":29104,"firstname":"Fulton","lastname":