Nested query bug?


(Zmicier) #1

Queries are automatically constructed in my system, and sometimes they
involve multiple levels of testing. Today I saw an example of two queries,
that seem equivalent to me, but they produce different results on run on
elastic. Perhaps Shay or others can clarify as to what is going on here.

Query #1 (straightforward "and' of two fields), 1723 results.

{
"query" : {
"bool" : {
"must" : [ {
"nested" : {
"query" : {
"range" : {
"content.publish_date" : {
"from" : null,
"to" : "2012-03-14T03:59:59.999Z",
"include_lower" : true,
"include_upper" : true
}
}
},
"path" : "content"
}
}, {
"nested" : {
"query" : {
"text" : {
"content.text" : {
"query" : "stop",
"type" : "boolean",
"operator" : "AND"
}
}
},
"path" : "content"
}
} ]
}
}
}

Query #2 (additional artificial nesting level is added wrapping the first
query, this is a dummy toy example just to show the behavior), although the
query seems to me totally equivalent to the first one, it produces 3376
results, with some results not satisfying both of "and" conditions.

{
"query" : {
"nested" : {
"query" : {
"bool" : {
"must" : [ {
"nested" : {
"query" : {
"range" : {
"content.publish_date" : {
"from" : null,
"to" : "2012-03-14T03:59:59.999Z",
"include_lower" : true,
"include_upper" : true
}
}
},
"path" : "content"
}
}, {
"nested" : {
"query" : {
"text" : {
"content.text" : {
"query" : "stop",
"type" : "boolean",
"operator" : "AND"
}
}
},
"path" : "content"
}
} ]
}
},
"path" : "content"
}
}
}

Anybody understands what is going on here?


(system) #2