The key difference between your 2 queries looks to be the inclusion of
in the must and must_not clauses.
Have you compared the queries using the Search Profiler and checked the results returned by each query? Can you explain more what documents you expect to return?
In this particular case with the conflicting clauses (jondoe must and must not exist) it would be impossible for an optimisation algorithm to automatically know which of the 2 clauses you would want to keep.
Assisting with change rather than automating would be of use here and one area I have experimented with is using custom aggregations and Sankey diagrams to show how individual clauses in a given query match (or don’t) and this would have red-flagged your must_not clause as rejecting 100% of the documents fed to it by all the other query clauses.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.