佛山网站建设邓先生,那个旅游网站可以做行程,太原企业网站模板建站,在线查询企业文章目录 一、单个使用二、must和must_not组合#xff08;A-B#xff09;三、must和should组合#xff08;A#xff09;四、should和must_not组合#xff08;A-B#xff09;五、must和should和must_not组合#xff08;A-C#xff09;六、验证脚本#xff0c;执行之后自… 文章目录 一、单个使用二、must和must_not组合A-B三、must和should组合A四、should和must_not组合A-B五、must和should和must_not组合A-C六、验证脚本执行之后自行观察结果price字段用来测试即可理解查考文档 一、单个使用
must且数组里面的条件都要满足该条数据才被选择所有的条件为且的关系must_not或然后取反数组里面的条件满足其中一个该条数据则不被选择should或数组里面的条件满足其中一个该条数据被选择
二、must和must_not组合A-B
满足must的数据减去满足must_not的数据则是最终结果
三、must和should组合A
满足must的数据should用来打分字段为_score 影响返回排序满足should条件的数据分值会更高
四、should和must_not组合A-B
满足should的数据减去满足must_not的数据则是最终结果
五、must和should和must_not组合A-C
满足must的数据减去满足must_not的数据则是最终结果should用来打分影响返回排序满足should条件的数据分值会更高
六、验证脚本执行之后自行观察结果price字段用来测试即可理解
初始化数据
POST mystore/_bulk
{index:{_id:1}}
{price:10,productID:XHDK-A-1293-#fJ3}
{index:{_id:2}}
{price:20,productID:XHDK-A-1293-#f20}
{index:{_id:3}}
{price:30,productID:JODL-X-1937-#pV7}
{index:{_id:4}}
{price:40,productID:QQPX-R-3956-#aD8}
{index:{_id:5}}
{price:50,productID:KDKE-B-9947-#kL5}
{index:{_id:6}}
{price:60,productID:KDKE-B-9947-#kL5}
{index:{_id:7}}
{price:70,productID:JODL-X-1937-#pV7}
{index:{_id:8}}
{price:80,productID:JODL-X-1937-#pV7}must和must_not组合
GET mystore/_search
{query: {bool: {must: [{range: {price: {gte: 20,lte: 50}}}],must_not: [{match: {price: 40}}]}}
}must和should组合
GET mystore/_search
{query: {bool: {must: [{range: {price: {gte: 20,lte: 50}}}],should: [{range: {price: {gte: 40,lte: 60}}}]}}
}should和must_not组合
GET mystore/_search
{query: {bool: {should: [{range: {price: {gte: 40,lte: 60}}}],must_not: [{match: {price: 40}}]}}
}must和should和must_not组合
GET mystore/_search
{query: {bool: {must: [{range: {price: {gte: 20,lte: 50}}}],should: [{range: {price: {gte: 40,lte: 60}}}],must_not: [{match: {price: 40}}]}}
}查考文档
must,must_not,should组合关系以及OR和AND