《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(11) https://developer.aliyun.com/article/1231060
命中为 0,因为没有标题中包含 “苹果 高清 英寸” 词组的商品信息,这里的 and 是将查询条件做分词处理,然后查询结果时,必须全部包含 “苹果 高清 英寸” 分词词组才能被检索,下面再演示下 or 的例子:
GET /my_goods/_search { "query": { "match": { "goodsName": { "query": "苹果 高清 英寸", "operator": "or" } } } } #返回 { "_index" : "my_goods", "_type" : "_doc", "_id" : "4", "_score" : 1.836855, "_source" : { "shopCode" : "sc00001", "brandName" : "山东苹果", "closeUserCode" : [ "uc001", "uc002", "uc003" ], "skuCode_brandName" : "skuCode4山东苹果", "channelType" : "cloudPlatform", "publicPrice" : 16977.76, "goodsName_length" : 31, "groupPrice" : [ { "level" : "level1", "boxLevelPrice" : "2488.88" }, { "level" : "level2", "boxLevelPrice" : "3488.88" } ], "boxPrice" : [ { "boxType" : "box1", "boxUserCode" : [ "uc004", "uc005", "uc006", "uc001" ], "boxPriceDetail" : 4488.88 }, { "boxType" : "box2", "boxUserCode" : [ "htd007", "htd008", "htd009", "uc0010" ], "boxPriceDetail" : 5488.88 } ], "boostValue" : 1.2, "goodsName" : "山东苹果UA55RU7520JXXZ 苹果54英寸 5K超高清", "skuCode" : "skuCode4" } }, { "_index" : "my_goods", "_type" : "_doc", "_id" : "10", "_score" : 0.9227071, "_source" : { "goodsName" : "三星UA55RU7520JXXZ 52英寸 4K超高清", "skuCode" : "skuCode10", "brandName" : "三星", "closeUserCode" : [ "uc0022" ], "channelType" : "cloudPlatform", "shopCode" : "sc00001", "publicPrice" : "8288.88", "groupPrice" : null, "boxPrice" : [ { "boxType" : "box1", "boxUserCode" : [ "uc0022" ], "boxPriceDetail" : 4288.88 } ], "boostValue" : 1.8, "city" : "cloudPlatform1" } }
可以看到,“三星 UA55RU7520JXXZ 52 英寸 4K 超高清” 由于包含 “高清” 所以能被查询到。
Match phrase query
用于匹配索引中是否存在所输入的查询条件数据:
GET /my_goods/_search { "query": { "match_phrase": { "goodsName": "apple" } } }
《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(13) https://developer.aliyun.com/article/1231057