Я пытаюсь выполнить этот запрос на моем ElasticSearch Server.
{
"query" : {
"match" : {
"name" : "network"
}
},
"facets" : {
"departments" : {
"terms" : {
"field" : "department_name"
}
}
},
"filter" : {
"bool": {
"should": [
{ "match" : {"department_name" : "book"}},
{ "match" : {"department_name" : "electronics"}}]
}
}
}
В принципе, я хочу получить все продукты, которые соответствуют "сети" в его имени, но фильтрует только те, которые department_name
соответствуют либо book
, либо electronics
. Когда я выполняю этот запрос, я получаю это сообщение об ошибке.
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 [{\n \"query\" : {\n \"match\" : {\n \"name\" : \"network\"\n }\n },\n \"facets\" : {\n \"departments\" : { \n \"terms\" : {\n \"field\" : \"department_name\"\n } \n }\n },\n\n \"filter\" : {\n \"bool\": {\n \"should\": [\n { \"match\" : {\"department_name\" : \"book\"}},\n { \"match\" : {\"department_name\" : \"electronics\"}}] \n } \n }\n}\n]]]; 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 [{\n \"query\" : {\n \"match\" : {\n \"name\" : \"network\"\n }\n },\n \"facets\" : {\n \"departments\" : { \n \"terms\" : {\n \"field\" : \"department_name\"\n } \n }\n },\n\n \"filter\" : {\n \"bool\": {\n \"should\": [\n { \"match\" : {\"department_name\" : \"book\"}},\n { \"match\" : {\"department_name\" : \"electronics\"}}] \n } \n }\n}\n]]]; 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 [{\n \"query\" : {\n \"match\" : {\n \"name\" : \"network\"\n }\n },\n \"facets\" : {\n \"departments\" : { \n \"terms\" : {\n \"field\" : \"department_name\"\n } \n }\n },\n\n \"filter\" : {\n \"bool\": {\n \"should\": [\n { \"match\" : {\"department_name\" : \"book\"}},\n { \"match\" : {\"department_name\" : \"electronics\"}}] \n } \n }\n}\n]]]; 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 [{\n \"query\" : {\n \"match\" : {\n \"name\" : \"network\"\n }\n },\n \"facets\" : {\n \"departments\" : { \n \"terms\" : {\n \"field\" : \"department_name\"\n } \n }\n },\n\n \"filter\" : {\n \"bool\": {\n \"should\": [\n { \"match\" : {\"department_name\" : \"book\"}},\n { \"match\" : {\"department_name\" : \"electronics\"}}] \n } \n }\n}\n]]]; 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 [{\n \"query\" : {\n \"match\" : {\n \"name\" : \"network\"\n }\n },\n \"facets\" : {\n \"departments\" : { \n \"terms\" : {\n \"field\" : \"department_name\"\n } \n }\n },\n\n \"filter\" : {\n \"bool\": {\n \"should\": [\n { \"match\" : {\"department_name\" : \"book\"}},\n { \"match\" : {\"department_name\" : \"electronics\"}}] \n } \n }\n}\n]]]; nested: QueryParsingException[[products] No filter registered for [match]]; }]",
"status" : 400
}
Я полагаю, что ключ здесь QueryParsingException[[products] No filter registered for [match]]
, но не может понять, что здесь не так.