Nested or/and in filters


(xrado) #1

Hi,

is it possible to filter like this... a=1 AND b=1 AND ( d=NULL OR (e=3 AND d=1) ) ?
I've came to or/and filters but don't know how to nest them.

hope anyone can help


(xrado) #2

actually I only need a='something' AND ( date=NULL OR date>now )

anyone?


(Nicolas Lalevée) #3

Le 21 mai 2011 à 14:29, xrado a écrit :

actually I only need a='something' AND ( date=NULL OR date>now )

I am more used to use the Java lucene API, but since the elasticsearch DSL nicely match to the Lucene API, I think I can answer with this:

{
"bool" : {
"must" : [
{
"term" : { "a" : "something" }
},
{
"bool" : {
"should" : [
{
"term" : { "date" : "NULL" }
},
{
"range" : {
"date" : { "from" : "now" }
}
}
]
}
}
]
}
}

Nicolas


(xrado) #4

thx man! this is it


(system) #5