GeoDistanceQuery with boolean filter not returning results

Hi all,

I am using java to build up a search expression based on user inputs. It seems to work until I intersect a boolean query, filter and geodistance query. The very strange part is that searchResponse.getHits().getHits() is empty, yet searchResponse.getTotalRecords() is 1, which is expected.

Edit: I just ran the last query that returns no results from the command line using curl, and it returns 1 result as expected.

Much more detail here.

ElasticSearch version 2.3.2 server
ElasticSearch Java Library 2.3.1, and 2.3.3 tested, same results

First I filter by user:

  "query" : {
    "query_string" : {
      "query" : "OwnerId:(3694)"
    }
  },

This works as expected, and returns many results.

Then I add a query string:

  "query" : {
    "bool" : {
      "must" : {
        "query_string" : {
          "query" : "Summary:(\"business analyst\" AND qa)"
        }
      },
      "filter" : {
        "query_string" : {
          "query" : "OwnerId:(3694)"
        }
      }
    }
  },

This correctly returns exactly one result.

I remove the query, and add a GeoDistance search.

  "query" : {
    "bool" : {
      "filter" : [ {
        "query_string" : {
          "query" : "OwnerId:(3694)"
        }
      }, {
        "geo_distance" : {
          "Latlong" : [ -71.608545, 42.860306 ],
          "distance" : "30.0mi",
          "optimize_bbox" : "memory"
        }
      } ]
    }
  },

This returns four results, including the result from the previous query.

Add the query string back in.

  "query" : {
    "bool" : {
      "must" : {
        "query_string" : {
          "query" : "Summary:(\"business analyst\" AND qa)"
        }
      },
      "filter" : {
        "bool" : {
          "filter" : [ {
            "query_string" : {
              "query" : "OwnerId:(3694)"
            }
          }, {
            "geo_distance" : {
              "Latlong" : [ -71.608545, 42.860306 ],
              "distance" : "30.0mi",
              "optimize_bbox" : "memory"
            }
          } ]
        }
      }
    }
  },

And now I get no results, searchResult.getHits().getHits() is empty, but the searchResult object claims there is 1 total record.

If anyone has any suggestions on what I should try next, I'd certainly appreciate them.

Thanks in advance
Tony

Here is another example, that works fine using curl, and returns 16 results. The java searchResponse.getHits().getTotalHits() returns 16, but searchResponse.getHits().getHits() is empty.

This is the complete query.

{
  "from" : 0,
  "size" : 25,
  "query" : {
    "bool" : {
      "must" : {
        "query_string" : {
          "query" : "(_all:((\"revenue cycle\" OR RCM) AND ny) OR Summary:((\"revenue cycle\" OR RCM) AND ny))"
        }
      },
      "filter" : {
        "bool" : {
          "filter" : [ {
            "query_string" : {
              "query" : "OwnerId:(1009)"
            }
          }, {
            "geo_distance" : {
              "Latlong" : [ -73.697796, 40.757711 ],
              "distance" : "30.0mi",
              "optimize_bbox" : "memory"
            }
          } ]
        }
      }
    }
  },
  "_source" : {
    "includes" : [ "FirstName", "LastName", "RecruiterId", "RecruiterName", "Location", "VisaStatus", "LastEmailDate", "Email", "SecondaryEmail", "Summary", "OwnerId", "OwnerActive", "HasHiredTrades", "AttachmentData", "Claimable" ],
    "excludes" : [ ]
  },
  "sort" : [ {
    "_score" : { }
  } ]
}

Again, thanks in advance for any insight.
Tony

I hate too keep bumping my own post, but I'm out of ideas.

I've ensured that 'from' is always 0, and size is very reasonable at 25. I've tested different query types, and this always seems to break the same way.

The fact that that searchResult knows there should be something there, but hits is empty is just baffling.

Is there any other data I can post? Or anywhere else I should post this?

I really need to get a fix for this out as soon as possible.

Thanks
Tony