《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(6) https://developer.aliyun.com/article/1231065
以上查询表示 brandName 包含“东” 和 “果” 至少匹配成功一次,查询结果如下:
"hits" : [ { "_index" : "my_goods", "_type" : "_doc", "_id" : "4", "_score" : 1.5678144, "_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" : "2", "_score" : 0.2792403, "_source" : { "shopCode" : "sc00002", "brandName" : "苹果", "closeUserCode" : [ "0" ], "skuCode_brandName" : "skuCode2苹果", "channelType" : "cloudPlatform", "publicPrice" : 12377.76, "goodsName_length" : 13, "groupPrice" : null, "boxPrice" : null, "boostValue" : 1.0, "goodsName" : "苹果 55英寸 3K超高清", "skuCode" : "skuCode2" } }, { "_index" : "my_goods", "_type" : "_doc", "_id" : "1", "_score" : 0.2792403, "_source" : { "shopCode" : "sc00001", "brandName" : "苹果", "closeUserCode" : [ "0" ], "skuCode_brandName" : "skuCode1苹果", "channelType" : "cloudPlatform", "publicPrice" : 32755.52, "goodsName_length" : 13, "groupPrice" : null, "boxPrice" : null, "boostValue" : 1.8, "goodsName" : "苹果 51英寸 4K超高清", "skuCode" : "skuCode1" } }, { "_index" : "my_goods", "_type" : "_doc", "_id" : "3", "_score" : 0.21222264, "_source" : { "shopCode" : "sc00001", "brandName" : "美国苹果", "closeUserCode" : [ "0" ], "skuCode_brandName" : "skuCode3美国苹果", "channelType" : "cloudPlatform", "publicPrice" : 16777.76, "goodsName_length" : 26, "groupPrice" : null, "boxPrice" : [ { "boxType" : "box1", "boxUserCode" : [ "htd003", "uc004" ], "boxPriceDetail" : 4388.88 }, { "boxType" : "box2", "boxUserCode" : [ "uc005", "uc0010" ], "boxPriceDetail" : 5388.88 } ], "boostValue" : 1.2, "goodsName" : "苹果UA55RU7520JXXZ 53英寸 4K高清", "skuCode" : "skuCode3" } }, ... ]
当我们调整 minimum_should_match 为 2 时观察结果返回:
POST /my_goods/_search { "query": { "bool": { "should": [ { "term": { "brandName": { "value": "东" 320 > 三、产品能力 } } }, { "term": { "brandName": { "value": "果" } } } ], "minimum_should_match" : 2 } } } #返回: "hits" : [ { "_index" : "my_goods", "_type" : "_doc", "_id" : "4", "_score" : 1.5678144, "_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" } } ]
可以看到,只有 goodsName 出现 “东” 和 “果” 2 次以及 2 次以上的结果被查询到。
《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(8) https://developer.aliyun.com/article/1231063