Search w/Filter Error Message Confusing

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

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: Query DSL: Improve `or` and `and` filters to accept just array of filters · Issue #336 · elastic/elasticsearch · GitHub.

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