elasticsearch 两种不同索引的elasticsearch中的不同行为,elasticsearch,filter,mapping,elasticsearch,Filter,Mapping" /> elasticsearch 两种不同索引的elasticsearch中的不同行为,elasticsearch,filter,mapping,elasticsearch,Filter,Mapping" />

elasticsearch 两种不同索引的elasticsearch中的不同行为

elasticsearch 两种不同索引的elasticsearch中的不同行为,elasticsearch,filter,mapping,elasticsearch,Filter,Mapping,我有两种不同的行为,两个查询完全相同 在我的第一个查询中,must\u not子句没有过滤brand3,brand4返回brand3和brand4产品。但是,第二个查询不能工作 第一次查询: GET firstindex/product/_search { "filter":{ "bool": { "should": [ {"bool": {

我有两种不同的行为,两个查询完全相同

在我的第一个查询中,must\u not子句没有过滤brand3brand4返回brand3和brand4产品。但是,第二个查询不能工作

第一次查询:

GET firstindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                      {"bool": {
                            "must_not":{ "terms": {"brand.raw": ["brand3,brand4"]}
                            },
                            "must":{
                                "term" : {"retailer" : "retailer1"}    
                            }
                         }
                      }
                    ]
                }    
            }

    ,
    "size":10000
}
GET secondindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                       {"bool": {
                            "must_not": { "terms": {"brand.raw": ["brand1,brand2"]}
                            },
                            "must":{
                                "term" : {"retailer" : "retailer2"}    
                            }
                         }
                      }
                    ]
                }    
            }

    ,
    "size":10000
}
 "brand":{
                  "type":"string",
                  "fields":{
                     "raw":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               }
第二次查询:

GET firstindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                      {"bool": {
                            "must_not":{ "terms": {"brand.raw": ["brand3,brand4"]}
                            },
                            "must":{
                                "term" : {"retailer" : "retailer1"}    
                            }
                         }
                      }
                    ]
                }    
            }

    ,
    "size":10000
}
GET secondindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                       {"bool": {
                            "must_not": { "terms": {"brand.raw": ["brand1,brand2"]}
                            },
                            "must":{
                                "term" : {"retailer" : "retailer2"}    
                            }
                         }
                      }
                    ]
                }    
            }

    ,
    "size":10000
}
 "brand":{
                  "type":"string",
                  "fields":{
                     "raw":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               }
品牌映射为:

GET firstindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                      {"bool": {
                            "must_not":{ "terms": {"brand.raw": ["brand3,brand4"]}
                            },
                            "must":{
                                "term" : {"retailer" : "retailer1"}    
                            }
                         }
                      }
                    ]
                }    
            }

    ,
    "size":10000
}
GET secondindex/product/_search
{  
            "filter":{
                "bool": {
                    "should": [   
                       {"bool": {
                            "must_not": { "terms": {"brand.raw": ["brand1,brand2"]}
                            },
                            "must":{
                                "term" : {"retailer" : "retailer2"}    
                            }
                         }
                      }
                    ]
                }    
            }

    ,
    "size":10000
}
 "brand":{
                  "type":"string",
                  "fields":{
                     "raw":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               }
我被卡住了,我能做些什么来知道发生了什么

更新


我还尝试创建一个新的索引,从firstindex到first_索引,但它不起作用。最后,我可以修复这个改变,用brand_name而不是brand重新创建索引。我知道我不知道问题的根源,但这起了作用。

第一个条款在过滤器中有brand3,brand4,它是指1和2吗?@keety说的+你有两个不同的零售商,即
retailer1
retailer2
。。。您希望得到什么样的结果?您能提供一个示例输出吗both@Val如果“brand”在must_not子句中,并且在第一次查询中没有出现这种情况,那么我期望的结果是无法检索具有特定品牌的产品。您可以尝试使用POST而不是GET吗?