Understanding AND evaluation


(Neil Avery) #1

All,
After searching the docs and scouring the web Im hoping someone can help me
understand the evaluation of 'and' filters.

Conventionally, the short-circuit rules apply....i.e. fail on first clause
and go no further..

Can anyone confirm is this is the case?

I'd like to run the following however my native script is always executed
against data the fails the first clause. i.e. its hitting data where the
_host field is BBBB.local.

Regards,
Neil.

{
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"and" : {
"filters" : [ {
"term" : {
"_host" : "AAAA.local"
}
}, {
"script" : {
"script" : "ls-script",
"params" : {
"startMs" : 1406131440000,
"endMs" : 1406133300001
},
"lang" : "native"
}
} ]
}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/454e92b6-ff8f-4f99-b452-87ccd676337f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Adrien Grand) #2

Indeed the short-circuit rule applies. I tried to reproduce the issue
locally on master but didn't manage to.

How do you check that the native script is executed against data that fails
the first clause? Can you provide us with a curl recreation of the issue?

On Wed, Jul 23, 2014 at 6:31 PM, Neil Avery neil.avery@liquidlabs.co.uk
wrote:

All,
After searching the docs and scouring the web Im hoping someone can help
me understand the evaluation of 'and' filters.

Conventionally, the short-circuit rules apply....i.e. fail on first clause
and go no further..

Can anyone confirm is this is the case?

I'd like to run the following however my native script is always executed
against data the fails the first clause. i.e. its hitting data where the
_host field is BBBB.local.

Regards,
Neil.

{
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"and" : {
"filters" : [ {
"term" : {
"_host" : "AAAA.local"
}
}, {
"script" : {
"script" : "ls-script",
"params" : {
"startMs" : 1406131440000,
"endMs" : 1406133300001
},
"lang" : "native"
}
} ]
}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/454e92b6-ff8f-4f99-b452-87ccd676337f%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/454e92b6-ff8f-4f99-b452-87ccd676337f%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7bfZqHU-qpOx3ng374WC6GtL6VLe2WZ_SJ7H9SE4neFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Neil Avery) #3

Thanks the reply Adrien.
I've taken another look and confirm that it was an error on my part (sorry)!

It is behaving as expected - my error was the term based filter was working
correctly and when changing it to a non-matching term it filtered out
everything as is expected.

Thanks again,
Neil.

On Thursday, July 24, 2014 9:18:31 AM UTC+1, Adrien Grand wrote:

Indeed the short-circuit rule applies. I tried to reproduce the issue
locally on master but didn't manage to.

How do you check that the native script is executed against data that
fails the first clause? Can you provide us with a curl recreation of the
issue?

On Wed, Jul 23, 2014 at 6:31 PM, Neil Avery <neil....@liquidlabs.co.uk
<javascript:>> wrote:

All,
After searching the docs and scouring the web Im hoping someone can help
me understand the evaluation of 'and' filters.

Conventionally, the short-circuit rules apply....i.e. fail on first
clause and go no further..

Can anyone confirm is this is the case?

I'd like to run the following however my native script is always executed
against data the fails the first clause. i.e. its hitting data where the
_host field is BBBB.local.

Regards,
Neil.

{
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"and" : {
"filters" : [ {
"term" : {
"_host" : "AAAA.local"
}
}, {
"script" : {
"script" : "ls-script",
"params" : {
"startMs" : 1406131440000,
"endMs" : 1406133300001
},
"lang" : "native"
}
} ]
}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/454e92b6-ff8f-4f99-b452-87ccd676337f%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/454e92b6-ff8f-4f99-b452-87ccd676337f%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/01e18637-8ccd-42c5-9f2d-8c556a4f2130%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4