基本查询
GET wf225/_search{"query": {"match_all": {}},"size": 2,//指定条数"sort": [ //排序{"CODE": {"order": "desc"}}],"_source": ["CREATORID","CODE"]//展示指定字段}
使用keyword查询
GET wf225/_search{"query": {"term": {"NAME": {"value": "test"}}}}GET wf225/_search{"query": {"terms": {"NAME": ["test_child1","test_child3"]}}}
查询指定范围
GET wf225/_search{"query": {"range": {"age": {"gte": 10,"lte": 20}}}}
查询指定前缀
GET wf225/_search{"query": {"prefix": {"NAME": {"value": "te"}}}}
通配符查询
GET wf225/_search{"query": {"wildcard": {"NAME": {"value": "test*"}}}}
指定id批量查询
GET wf225/_search{"query": {"ids": {"values": ["5744866d-df40-4ec5-86f5-d4af0529ec00","5744866d-df40-4ec5-86f5-d4af0529ec99"]}}}
模糊查询
GET wf225/_search{"query": {"fuzzy": {"NAME": {"value": "hild"}}}}
布尔查询
bool 关键字: 用来组合多个条件实现复杂查询 bool表达式查询
must: 相当于&& 同时成立
should: 相当于|| 成立一个就行
must_not: 相当于! 不能满足任何一个
GET wf225/_search{"query": {"bool": {"must": [{"fuzzy": {"NAME": {"value": "hild"}}}],"must_not": [{"match": {"NAME": "test_child3"}}],"should": [{"match": {"ID": "5744866d-df40-4ec5-86f5-d4af0529ec99"}}]}}}
高亮显示
GET wf225/_search{"query": {"terms": {"NAME": ["test_child1","test_child3"]}},"highlight": {"pre_tags": ["<span style='color:red'>"],"post_tags": ["</span>"],"require_field_match":true,"fields": {"*":{}}}}
分词后,多字段查询
GET wf225/_search{"query": {"multi_match": {"query": "test","fields": ["NAME","ID"]}}}
指定分词器查询
GET wf225/_search{"query": {"query_string": {"default_field": "NAME","query": "test","analyzer": "ik_max_word"}}}
