《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(17) https://developer.aliyun.com/article/1231052
Term 查询
返回确切的文档内容,避免对 text 字段类型使用 term GET my_goods/_search { "query": { "term": { "brandName": { "value": "三星", "boost": 1.0 } } } }
Terms 查询
Terms 返回一个或多个包含精确查询条件的文档信息:
GET /my_goods/_search { "query": { "terms": { "brandName": [ "美国", "三星" ], "boost": 1.0 } } }
Terms_set 查询
返回最小精确匹配成功的文档信息,terms_set 类似 terms 查询,只不过 terms_set 多定义了返回最小匹配的数量。
#新定义商品信息 PUT /my_goods_info { "mappings": { "properties": { "goodsName": { "type": "keyword" }, "sale_property": { "type": "keyword" }, "required_matches": { "type": "long" } } } } #添加3条商品测试数据 #销售属性 白色、64G、标品 PUT /my_goods_info/_doc/1?refresh { "name": "apple", "sale_property": [ "white", "64","standard" ], "required_matches": 2 } #黑色、32G、非标品 PUT /my_goods_info/_doc/2?refresh { "name": "apple", "sale_property": [ "black", "32","no standard" ], "required_matches": 2 } #黑色、64 非标品 PUT /my_goods_info/_doc/3?refresh { "name": "apple", "sale_property": [ "black", "64","no standard" ], "required_matches": 2 } #查询 GET /my_goods_info/_search { "query": { "terms_set": { "sale_property": { "terms": [ "white", "64"], "minimum_should_match_field": "required_matches" } } } } #返回 "hits" : [ { "_index" : "my_goods_info", "_type" : "_doc", "_id" : "1", "_score" : 1.1149836, "_source" : { "name" : "apple", "sale_property" : [ "white", "64", "standard" ], "required_matches" : 2 } } ]
《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(19) https://developer.aliyun.com/article/1231050