Open joelin109 opened 3 years ago
DSL(Domain Specific Language ), 以JSON的请求形式, 允许构建更复杂、强大的查询
全匹配(match_all)
"query": { "match_all": {} }
标准查询(match & match_phrase & multi_match)
"query": { "match": { "language" : "English, Chinese" } }
match: where 'English' in language or 'Chinese' in language 分词查询, 对text类型字段,会对文本先进行分词进行查询
"query": { "match_phrase": { "language" : "English, Chinese" } } }
match_phrase: where language like '%english, chinese'
- 单词搜索与过滤(Term和Terms)
"query": { "term": { "language" : "english" } } }
Similar: where 'english' in language 精确查询,通常对keyword和有精确值的字段进行查询
- ④ 组合条件搜索与过滤(Bool)
"query": { "bool": {
"must": [ { "match": {"language": "english, chinese"} }, { "term": {"address": "shanghai"} }, { "range": {"age": {"gte": 18,"lte": 40}} } ], "must_not": [ { "term": { "name": "john"} } ] }
}
- ⑤ 范围查询与过滤(range)
GET joe_dbase_index/_search { "query": { "range": { "age": { "gte": 18, "lte": 36 } } } }
where age >= 18 and age <=36
- ⑥ 存在和缺失过滤器(exists和missing)
- ⑦ 前匹配搜索与过滤(prefix)
https://www.jianshu.com/p/e589181b14db
ES的查询语言叫做DSL(结构化查询)
DSL(Domain Specific Language ), 以JSON的请求形式, 允许构建更复杂、强大的查询
全匹配(match_all)
标准查询(match & match_phrase & multi_match)
match: where 'English' in language or 'Chinese' in language 分词查询, 对text类型字段,会对文本先进行分词进行查询
"query": { "match_phrase": { "language" : "English, Chinese" } } }
match_phrase: where language like '%english, chinese'
"query": { "term": { "language" : "english" } } }
Similar: where 'english' in language 精确查询,通常对keyword和有精确值的字段进行查询
"query": { "bool": {
}
GET joe_dbase_index/_search { "query": { "range": { "age": { "gte": 18, "lte": 36 } } } }
where age >= 18 and age <=36