在默认的状况下,ES 是根据文档的得分score来进行文档额排序的。可是本身能够根据本身的针对一些字段进行排序。就像下面的查询脚本同样。下面的这个查询是根据productid这个值进行排序的,并且进行了双字段的排序。当productid 相同时的文档是根据下面的那个排序字段进行的排序html
POST /product/_search { "query": { "bool": { "filter": { "term": { "productSource": "2" } } } }, "sort": [ { "productId": { "order": "desc" } }, { "_score":{ "order": "desc" } } ] }
missing字段的查询是查那些不存在的字段的数据 POST /product/_search { "query": { "bool": { "filter": { "missing": { "field": "weight" } } } } } existing是查询那些已经存在字段的数据 POST /product/_search { "query": { "bool": { "filter": { "exists": { "field": "weight" } } } } }