ElasticSearch:没有为 [match]] 注册过滤器 [英] ElasticSearch: No filter registered for [match]]

查看:25
本文介绍了ElasticSearch:没有为 [match]] 注册过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对我的 ElasticSearch 服务器执行此查询.

I'm trying to do this query to my ElasticSearch Server.

{
    "query" : {
        "match" : {
            "name" : "network"
        }
    },
    "facets" : {
        "departments" : { 
            "terms" : {
                "field" : "department_name"
            } 
        }
    },

    "filter" : {
        "bool": {
            "should": [
                { "match" : {"department_name" : "book"}},
                { "match" : {"department_name" : "electronics"}}]            
        }   
    }
}

基本上,我希望检索其名称中与network"匹配的所有产品,但仅过滤那些与 department_name 匹配的 bookelectronics.当我执行此查询时,我收到此错误消息.

Basically, I wish to retrieve all the products that match "network" in its name, but filtering only to those which department_name matches either book or electronics. When I perform this query, I receive this error message.

curl -X POST "http://localhost:9200/products/_search?pretty=true" -d '{
    "query" : {
        "match" : {
            "name" : "network"
        }
    },
    "facets" : {
        "departments" : { 
            "terms" : {
                "field" : "department_name"
            } 
        }
    },

    "filter" : {
        "bool": {
            "should": [
                { "match" : {"department_name" : "book"}},
                { "match" : {"department_name" : "electronics"}}]            
        }   
    }
}
'

{
  "error" : "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[EaNRci0OSIqpA2EAPwAA6w][products][4]: SearchParseException[[products][4]: query[name:network],from[-1],size[-1]: Parse Failure [Failed to parse source [{
    "query" : {
        "match" : {
            "name" : "network"
        }
    },
    "facets" : {
        "departments" : { 
            "terms" : {
                "field" : "department_name"
            } 
        }
    },

    "filter" : {
        "bool": {
            "should": [
                { "match" : {"department_name" : "book"}},
                { "match" : {"department_name" : "electronics"}}]            
        }   
    }
}
]]]; nested: QueryParsingException[[products] No filter registered for [match]]; }{[EaNRci0OSIqpA2EAPwAA6w][products][0]: SearchParseException[[products][0]: query[name:network],from[-1],size[-1]: Parse Failure [Failed to parse source [{
    "query" : {
        "match" : {
            "name" : "network"
        }
    },
    "facets" : {
        "departments" : { 
            "terms" : {
                "field" : "department_name"
            } 
        }
    },

    "filter" : {
        "bool": {
            "should": [
                { "match" : {"department_name" : "book"}},
                { "match" : {"department_name" : "electronics"}}]            
        }   
    }
}
]]]; nested: QueryParsingException[[products] No filter registered for [match]]; }{[EaNRci0OSIqpA2EAPwAA6w][products][1]: SearchParseException[[products][1]: query[name:network],from[-1],size[-1]: Parse Failure [Failed to parse source [{
    "query" : {
        "match" : {
            "name" : "network"
        }
    },
    "facets" : {
        "departments" : { 
            "terms" : {
                "field" : "department_name"
            } 
        }
    },

    "filter" : {
        "bool": {
            "should": [
                { "match" : {"department_name" : "book"}},
                { "match" : {"department_name" : "electronics"}}]            
        }   
    }
}
]]]; nested: QueryParsingException[[products] No filter registered for [match]]; }{[EaNRci0OSIqpA2EAPwAA6w][products][2]: SearchParseException[[products][2]: query[name:network],from[-1],size[-1]: Parse Failure [Failed to parse source [{
    "query" : {
        "match" : {
            "name" : "network"
        }
    },
    "facets" : {
        "departments" : { 
            "terms" : {
                "field" : "department_name"
            } 
        }
    },

    "filter" : {
        "bool": {
            "should": [
                { "match" : {"department_name" : "book"}},
                { "match" : {"department_name" : "electronics"}}]            
        }   
    }
}
]]]; nested: QueryParsingException[[products] No filter registered for [match]]; }{[EaNRci0OSIqpA2EAPwAA6w][products][3]: SearchParseException[[products][3]: query[name:network],from[-1],size[-1]: Parse Failure [Failed to parse source [{
    "query" : {
        "match" : {
            "name" : "network"
        }
    },
    "facets" : {
        "departments" : { 
            "terms" : {
                "field" : "department_name"
            } 
        }
    },

    "filter" : {
        "bool": {
            "should": [
                { "match" : {"department_name" : "book"}},
                { "match" : {"department_name" : "electronics"}}]            
        }   
    }
}
]]]; nested: QueryParsingException[[products] No filter registered for [match]]; }]",
  "status" : 400
}

我想这里的关键是 QueryParsingException[[products] 没有为 [match]] 注册过滤器,但不明白这里出了什么问题.

I suppose the key here is QueryParsingException[[products] No filter registered for [match]], but cannot understand what's wrong here.

推荐答案

match 是一个查询,而不是一个过滤器.

match is a query, not a filter.

在这种情况下,您可能需要 term-filter.

You probably want the term-filter in this case.

这篇关于ElasticSearch:没有为 [match]] 注册过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆