Upside down range query - match a single value against records having ranges

hi,
I tried looking this up, but was not able to find any material. I am not
sure if I am attempting the impossible.
Consider the following document in ES:

{
"weight" : {
"greater" : 5000,
"lesser-or-equal" : 10000
},
"value" : "ABCD"
}

{
"weight" : {
"greater" : 1000,
"lesser-or-equal" : 2000
},
"value" : "XYZ"
}

What I want to do is search for weight = 7000 and match record "ABCD" but
not "XYZ". Basically, it is the opposite of range query, which lets you
specify a range in your query and matches single valued records. Here, I am
attempting to specify ranges in a document and query using a single valued
query.

I dont know if this can even be done - is there a workaround to this kind
of a behavior ?

Thanks!

What about a range with

{
"range" : {
"lesser-or-equal" : {
"from" : 7000
}
}
}

with :

{
"range" : {
"greater" : {
"to" : 7000
}
}
}

All in a bool query with must for both of them?

Does it make sense for your use case?

Le 7 août 2012 à 10:13, Sandeep Srinivasa sandys@gmail.com a écrit :

hi,
I tried looking this up, but was not able to find any material. I am not sure
if I am attempting the impossible.
Consider the following document in ES:

{
"weight" : {
"greater" : 5000,
"lesser-or-equal" : 10000
},
"value" : "ABCD"
}

{
"weight" : {
"greater" : 1000,
"lesser-or-equal" : 2000
},
"value" : "XYZ"
}

What I want to do is search for weight = 7000 and match record "ABCD" but not
"XYZ". Basically, it is the opposite of range query, which lets you specify a
range in your query and matches single valued records. Here, I am attempting
to specify ranges in a document and query using a single valued query.

I dont know if this can even be done - is there a workaround to this kind of
a behavior ?

Thanks!

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs