我在使用“ must_not”子句在弹性搜索中过滤搜索查询时遇到了一些问题
我为索引插入的映射
{
"monojit": {
"mappings": {
"banik": {
"properties": {
"productid": {
"type": "text",
"fields": {
"keyword": {
"type": "text"
}
}
},
"priority": {
"type": "integer"
},
"excludesku": {
"type": "text",
"fields": {
"keyword": {
"type": "text"
}
}
}
}
}
}
}
}
我已经一一插入下面提到的json数据
样本数据1:
{
"productid": "MP01212,MP0766,MP865578,MP8656889",
"excludesku": "98656890,86444326",
"priority":2,
}
样本数据2:
{
"productid": "MP01212",
"excludesku": "12345642570,32434434,3938463732",
"priority":1,
}
我的查询是
{
"query":{
"constant_score":{
"filter": {
"bool": {
"should": [
{
"bool": {
"must":{
"match": {
"productid": "MP01212"
}
},
"must_not":{
"match":{
"excludesku": "3938463732"
}
}
}
}
]
}
}
}
},
"sort" : {
"priority":{
"order":"asc"
}
}
}
我的查询给了我所有匹配,但我只希望结果中有“样本数据1”,但不幸的是“ excludeussid”字段无法正常工作。请建议我。
尝试: