{ "from": 0, "size": 10, "query": { "bool": { "must": [ { "bool": { "should": [ { "term": { "status": 2 } }, { "term": { "tier": 3 } } ] } }, { "term": { "media_id": 102050 } } ], "should": [ { "term": { "actions": 3 } } ], "must_not": [ { "term": { "duration": "304" } } ], "filter": [ { "range": { "duration": { "gte": 20, "lt": 309 } } }, { "range": { "approved_time": { "lt": 1486531465338 } } } ] } }, "sort": [ { "duration": { "order": "desc" } }, { "created_time": { "order": "desc" } } ] }
以上是总结
从0条开始,查看10条
GET /_search { "from" : 0, "size" : 10, "query" : { "term" : { "user" : "kimchy" } } }排序,根据post_date进行升序GET /my_index/my_type/_search
{
"sort" : [
{ "post_date" : {"order" : "asc"}}
],
"query" : {
"term" : { "user" : "kimchy" }
}
}
asc:升序
desc:降序
除此外,还可以根据复杂类型进行排序,不过需要对复杂类型定义需要排序的定义
字段过滤(即那些字段不展示,那些字段展示)
GET /_search { "_source": "obj.*", "query" : { "term" : { "user" : "kimchy" } } }
或者
GET /_search { "_source": [ "obj1.*", "obj2.*" ], "query" : { "term" : { "user" : "kimchy" } } }
或者
GET /_search { "_source": { "includes": [ "obj1.*", "obj2.*" ], "excludes": [ "*.description" ] }, "query" : { "term" : { "user" : "kimchy" } } }
搜索颜色为红色且品牌为gucci的数据
GET /shirts/_search { "query": { "bool": { "filter": [ { "term": { "color": "red" }}, { "term": { "brand": "gucci" }} ] } } }
对上面的数据分组展示
GET /shirts/_search { "query": { "bool": { "filter": [ { "term": { "color": "red" }}, { "term": { "brand": "gucci" }} ] } }, "aggs": { "models": { "terms": { "field": "model" } } } }
高亮content列
GET /_search { "query" : { "match": { "content": "kimchy" } }, "highlight" : { "fields" : { "content" : {} } } }
解释分数如何计算
GET /_search { "explain": true, "query" : { "term" : { "user" : "kimchy" } } }
当前文档的版本
GET /_search { "version": true, "query" : { "term" : { "user" : "kimchy" } } }
排除分数小于指定值
GET /_search { "min_score": 0.5, "query" : { "term" : { "user" : "kimchy" } } }