Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inner_hits does not work for nested filters #10308

Closed
damienbod opened this issue Mar 29, 2015 · 4 comments
Closed

inner_hits does not work for nested filters #10308

damienbod opened this issue Mar 29, 2015 · 4 comments
Labels

Comments

@damienbod
Copy link

I'm updating a .NET client to support inner_hits for nested, has_child and has_parent queries and filters.

The inner_hits work for all queries and filters except nested filters. Is this a bug or a documentation error?

{
    "filter": {
        "nested": {
            "path": "skillchildren",
            "filter": {
                "match_all": { }
            },
            "inner_hits": { }
        }
    }
}

Greetings Damien

@martijnvg
Copy link
Member

@damienbod inner_hits in a nested filter should work. I quickly tried to verified that inner_hits works in a nested filter. If it doesn't work in your case can you share your reproduction of the issue?

@damienbod
Copy link
Author

Hi Thanks for your reply. Here's my data:

Mapping:

PUT http://localhost:9200/nestedcollectiontests/nestedcollectiontest/_mappings HTTP/1.1
Content-Type: application/json
Host: localhost:9200
Content-Length: 616
Expect: 100-continue

{"nestedcollectiontest":{"properties":{"id":{ "type" : "long" },"nameskillparent":{ "type" : "string" },"descriptionskillparent":{ "type" : "string" },"createdskillparent":{ "type" : "date", "format": "dateOptionalTime"},"updatedskillparent":{ "type" : "date", "format": "dateOptionalTime"},"skillchildren":{"type":"nested","include_in_parent":true,"properties":{"id":{ "type" : "long" },"nameskillchild":{ "type" : "string" },"descriptionskillchild":{ "type" : "string" },"createdskillchild":{ "type" : "date", "format": "dateOptionalTime"},"updatedskillchild":{ "type" : "date", "format": "dateOptionalTime"}}}}}}

Test Data:

POST http://localhost:9200/_bulk HTTP/1.1
Content-Type: application/json
Host: localhost:9200
Content-Length: 906
Expect: 100-continue

{"index":{"_index":"nestedcollectiontests","_type":"nestedcollectiontest","_id":8}}
{"id":8,"nameskillparent":"cool","descriptionskillparent":"A test entity description","createdskillparent":"2015-03-29T20:59:51.0179334+00:00","updatedskillparent":"2015-03-29T20:59:51.0179334+00:00","skillchildren":[{"id":0,"nameskillchild":"cool","descriptionskillchild":"A test SkillChild description","createdskillchild":"2015-03-29T20:59:51.0159335+00:00","updatedskillchild":"2015-03-29T20:59:51.0159335+00:00"},{"id":1,"nameskillchild":"cool","descriptionskillchild":"A test SkillChild description","createdskillchild":"2015-03-29T20:59:51.0159335+00:00","updatedskillchild":"2015-03-29T20:59:51.0159335+00:00"},{"id":2,"nameskillchild":"cool","descriptionskillchild":"A test SkillChild description","createdskillchild":"2015-03-29T20:59:51.0159335+00:00","updatedskillchild":"2015-03-29T20:59:51.0159335+00:00"}]}

Search Request:

POST http://localhost:9200/nestedcollectiontests/nestedcollectiontest/_search HTTP/1.1
Content-Type: application/json
Host: localhost:9200
Content-Length: 88
Expect: 100-continue

{"filter":{"nested":{"path":"skillchildren","filter":{"match_all":{}},"inner_hits":{}}}}

Response:

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Content-Length: 1997

{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[g6ANIIX0SieBnVvi3jhjJA][nestedcollectiontests][0]: SearchParseException[[nestedcollectiontests][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"filter\":{\"nested\":{\"path\":\"skillchildren\",\"filter\":{\"match_all\":{}},\"inner_hits\":{}}}}]]]; nested: QueryParsingException[[nestedcollectiontests] [nested] requires either 'query' or 'filter' field]; }{[g6ANIIX0SieBnVvi3jhjJA][nestedcollectiontests][1]: SearchParseException[[nestedcollectiontests][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"filter\":{\"nested\":{\"path\":\"skillchildren\",\"filter\":{\"match_all\":{}},\"inner_hits\":{}}}}]]]; nested: QueryParsingException[[nestedcollectiontests] [nested] requires either 'query' or 'filter' field]; }{[g6ANIIX0SieBnVvi3jhjJA][nestedcollectiontests][2]: SearchParseException[[nestedcollectiontests][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"filter\":{\"nested\":{\"path\":\"skillchildren\",\"filter\":{\"match_all\":{}},\"inner_hits\":{}}}}]]]; nested: QueryParsingException[[nestedcollectiontests] [nested] requires either 'query' or 'filter' field]; }{[g6ANIIX0SieBnVvi3jhjJA][nestedcollectiontests][3]: SearchParseException[[nestedcollectiontests][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"filter\":{\"nested\":{\"path\":\"skillchildren\",\"filter\":{\"match_all\":{}},\"inner_hits\":{}}}}]]]; nested: QueryParsingException[[nestedcollectiontests] [nested] requires either 'query' or 'filter' field]; }{[g6ANIIX0SieBnVvi3jhjJA][nestedcollectiontests][4]: SearchParseException[[nestedcollectiontests][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"filter\":{\"nested\":{\"path\":\"skillchildren\",\"filter\":{\"match_all\":{}},\"inner_hits\":{}}}}]]]; nested: QueryParsingException[[nestedcollectiontests] [nested] requires either 'query' or 'filter' field]; }]","status":400}

Elasticsearch version:

{

    "status": 200,
    "name": "Shen Kuei",
    "cluster_name": "elasticsearch",
    "version": 

    {
        "number": "1.5.0",
        "build_hash": "544816042d40151d3ce4ba4f95399d7860dc2e92",
        "build_timestamp": "2015-03-23T14:30:58Z",
        "build_snapshot": false,
        "lucene_version": "4.10.4"
    },
    "tagline": "You Know, for Search"

}

Thanks for your help.

Greetings Damien

@martijnvg
Copy link
Member

Hey @damienbod this is a bug. Thanks for sharing your data!

It only manifest if a inner filter is used in the nested filter. If a inner query is used instead then the issue doesn't occur, so the following works:

{
    "filter": {
        "nested": {
            "path": "skillchildren",
            "query": {
                "match_all": { }
            },
            "inner_hits": { }
        }
    }
}

@damienbod
Copy link
Author

No problem
Thanks for looking
greetings Damien

martijnvg added a commit that referenced this issue Mar 31, 2015
martijnvg added a commit that referenced this issue Mar 31, 2015
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants