OR'd Range Queries

Just starting with ElasticSearch and am a bit tentative. Did study the
guide, but have a few questions about what can get nested where, so please
bear with me.

I need to AND numerous criteria (dynamically according to user entry). I
presume that "must" under bool is like "and" under filter? If so, the
example below will AND the elements of criteria:
{
"bool":
{
"must":[
{"query_string":
{"query": "myStuff", "allow_leading_wildcard": true,
"phrase_slop": 0}
},
{"term": {"lastName":"Smith"}},
{"range":{"age":{"from":"10", "to":"20"}}}
]
}
}

The thing I would like to AND to the above structure is/are additional
RANGE queries, which themselves have OR'd criteria. Can I effectively OR
RANGE criteria like this?:
{
"range" : {
"age" : {
"from" : 10,
"to" : 20
}
"age" : {
"from" : 30,
"to" : 40
}
}
}
Then AND that block to the "must" array in the 1st structure. Will
ElasticSearch find indexes for multiple age ranges in this case from this
syntax? Is there a better way? Thanks.

Oops on the 2nd JSON above. Obviously I can't have the >1 age member in the
same object. Is there a way to group multiple from/to criteria in [] under
"age" so that it affect an OR'd search?

Heya,

Yea, sure, you can do it. What you need in this case is to have another
bool query for the range parts, with two should clauses. The range bool
query will exists within the outer bool query (simply place it where the
current range query is at).

On Tue, Nov 1, 2011 at 11:43 PM, CliffB bentley.cliff@gmail.com wrote:

Oops on the 2nd JSON above. Obviously I can't have the >1 age member in
the same object. Is there a way to group multiple from/to criteria in
under "age" so that it affect an OR'd search?