Closed ayadav77 closed 8 years ago
The has_child
query operates at the index level, you cannot restrict the type of your query like you're doing in your snippet:
GET /sandbox/questions/_search
Try with
/sandbox/_search
The has_child query operates at the index level, you cannot restrict the type of your query like you're doing in your snippet:
This is possible, since 2.0 if I recall correctly.
This really seems to be caused by a bug in: HasChildQueryBuilder#rewrite(...)
Fixing that makes the query work as expected. I'll open a PR.
Elasticsearch version: 5.0.0-alpha4
JVM version: 1.8.0_60
Description of the problem including expected versus actual behavior: The has_child query does not return expected results when it contains a date based range query. I created a document type called questions which has a child document type called answers. The answers document has a date field. Once I insert sample data in elasticsearch, I can query the answers document successfully with a date range query. However, the has_child query does not return any results when the date range query utilizes any date value that precedes the answer dates. The following steps explain the issue further.
Steps to reproduce: 1) Create an index called "sandbox"
2) Create a document mapping for "answers" with a parent type of "questions".
3) Add a "questions" document
4) Add a couple of "answers" document
5) Find all answers with a date value of gte "2016-04-01". THIS WORKS AS EXPECTED. It returns the 2 answers documents as expected.
6) Now use the has_child query to get questions with answers that have date gte "2016-04-01". DOES NOT WORK AS EXPECTED. This returns 0 hits. I expected the 1 "questions" document in the response.