Search w/Filter Error Message Confusing


(Kenneth Loafman) #1

Hi,

The following query gets the error:
"[filtered] requires a 'query' element"
yet its clear from the json dump of the query that 'query' is in the
'filtered' dictionary, so what's the real problem?

{
"query": {
"filtered": {
"filter": {
"or": [
{
"term": {
"lang": "en"
}
},
{
"term": {
"lang": "es"
}
}
]
},
"query": {
"query_string": {
"use_dis_max": true,
"fields": [
"content",
"title",
"author_name"
],
"query": "xxxxxxx"
},
"from": 50,
"size": 3
}
}
}
}

...Thanks,
...Ken


(Shay Banon) #2

The query is malformed. The or/and filters need an inner filters element
in them. What happens is that it screws up the pull parsing. I just pushed
some things to improve on that. The first is to throw an exception if no
filters are identified for or/and parsing. The second is nicer format for
it: http://github.com/elasticsearch/elasticsearch/issues/issue/336.

One more thing, the size and from should be "top level" fields.

-shay.banon

On Wed, Aug 25, 2010 at 5:47 PM, Kenneth Loafman
kenneth.loafman@gmail.comwrote:

Hi,

The following query gets the error:
"[filtered] requires a 'query' element"
yet its clear from the json dump of the query that 'query' is in the
'filtered' dictionary, so what's the real problem?

{
"query": {
"filtered": {
"filter": {
"or": [
{
"term": {
"lang": "en"
}
},
{
"term": {
"lang": "es"
}
}
]
},
"query": {
"query_string": {
"use_dis_max": true,
"fields": [
"content",
"title",
"author_name"
],
"query": "xxxxxxx"
},
"from": 50,
"size": 3
}
}
}
}

...Thanks,
...Ken


(system) #3