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

Changed inner_hits to work with the new join field type and #25074

Merged
merged 1 commit into from
Jun 7, 2017

Conversation

martijnvg
Copy link
Member

at the same time maintaining support for the _parent meta field type.

Relates to #20257

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for rewriting all the tests.
I left one comment. I think we need to be explicit when we build the inner hit query.

continue;
}

String parentIdFieldName = ParentJoinFieldMapper.getParentIdFieldName(joinFieldMapper.name(), typeName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the leniency and make sure that we build parent or children inner hits depending on the context. hasParent should only build inner hits of parent documents and hasChild for children documents.
With this information in JoinFieldInnerHitSubContext you can just call:

joinFieldMapper.getJoinFieldMapper(typeName, isParentInnerHits);

and use JoinFieldMapper#hasParent and JoinFieldMapper#hasChild to build the inner hits query ?

QueryShardContext qsc = context.getQueryShardContext();

Query q;
if (parentIdField == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if the document is a child and a parent ? I think it's simpler if we use the context directly.
hasParent expects a child and builds parent inner hits. hasChildren expects a parent and builds children inner hits ?

@martijnvg
Copy link
Member Author

@jimczi I made the join field inner hits logic more explicit.

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

at the same time maintaining support for the `_parent` meta field type/

Relates to elastic#20257
@Yneth
Copy link

Yneth commented Nov 28, 2017

My mapping
{ "mappings": { "test": { "properties": { "views": { "type": "nested", "properties": { "date": { "type": "date" } } } } } } }

My query to sort by view count
{ "query": { "has_child": { "type": "views", "score_mode": "sum", "query": {"match_all": {}}, // here I would also like to add some filtering by date "inner_hits": {} } } }

throws
{ "error": { "root_cause": [ { "type": "query_shard_exception", "reason": "[has_child] no join field has been configured", "index_uuid": "XW9AAGtjRtutQ3n4mhZ9zQ", "index": "test" } ], "type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true, "failed_shards": [ { "shard": 0, "index": "test", "node": "_bbwp3g_TfOGbZE4McKnjw", "reason": { "type": "query_shard_exception", "reason": "[has_child] no join field has been configured", "index_uuid": "XW9AAGtjRtutQ3n4mhZ9zQ", "index": "test" } } ] }, "status": 400 }

@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Inner Hits labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search/Search Search-related issues that do not fall into other categories v5.6.0 v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants