方便做测试,在es-head上比较方便,毕竟json难写........
1、多字段/全文检索
{ "query": { "multi_match": { "query": "xxxx", "fields" : ["field1","field2"] } } }
fields:指定要检索的字段,去掉fields,表示不限定字段
2、分页+match检索
{ "query": { "match": { "name": "kobe" } }, "size": 20, "from": 0, "_source": ["name", "team", "score"], "highlight": { "fields": { "name": {} } } }
3、bool查询
bool-must/must_not/should
4、通配符查询
{ "query": { "wildcard": { "name": { "value": "ko*" } } }, "_source": ["name", "team"] }
5、匹配短语查询
{ "query": { "multi_match": { "query": "search engine", "fields": ["title", "summary"], "type": "phrase", "slop": 3 } }, "_source": [ "title", "summary", "publish_date" ] }
6、range
{ "query": { "range": { "create_time": { "gte": "2015-01-01", "lte": "2015-12-31" } } } }