赞
踩
POST /t1/_doc/ { "name":"cat", "age":"18", "address":"BJ", "job":"dev" } POST /t1/_doc/ { "name":"dog", "age":"19", "address":"SD", "job":"ops" } POST /t1/_doc/ { "name":"alice", "age":"20", "address":"BJ", "job":"dev" } POST /t1/_doc/ { "name":"tigger", "age":"20", "address":"AH", "job":"ops" } POST /t1/_doc/ { "name":"fix", "age":"21", "address":"HN", "job":"dev" } POST /t1/_doc/ { "name":"jack", "age":"18", "address":"BJ", "job":"dev" } POST /t1/_doc/ { "name":"Tom", "age":"21", "address":"HN", "job":"ops" }
#term查询,是根据具体的字段进行查询 #查询所有 GET t1/_search #查询name为cat的 GET t1/_search { "query": { "term": { "name.keyword": { "value": "cat" } } } } #查询地区为北京的 GET t1/_search { "query": { "term": { "address.keyword": { "value": "BJ" } } } } #bool查询 逻辑判断是否 bool组合语法 must:必须符合,包含 与AND等价 should:满足任意的条件, 与or等价 filter:必须满足,是否命中,不计算分值,等同must must_not: 必须不符合不包含 与not等价 #查询工作为ops的,且年龄为19到20岁的 GET t1/_search { "query": { "bool": { "must": [ {"match": { #我要查询job必须是包含ops的 "job": "ops" }} ], "filter": [ { "range": { "age.keyword": { "gte": 19, "lte": 20 } } } ] } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。