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

Access to child/parent fields of a document within a script #1017

Closed
ofavre opened this issue Jun 10, 2011 · 11 comments
Closed

Access to child/parent fields of a document within a script #1017

ofavre opened this issue Jun 10, 2011 · 11 comments
Labels

Comments

@ofavre
Copy link

ofavre commented Jun 10, 2011

Similar to #761 where it is asked to join the parent and child within the search result.

It would be nice to have access to the child documents- (and/or the parent document-) 's fields to be able to perform some lookup and script scoring or create a script field.

Examples:

  • Calculating some complex aggregation on children documents. (as script field)
  • Scoring a parent document depending on some complex aggregation on children documents. (as score script)
  • Just about the same, but manipulating the child document based on its parent.
@oyiptong
Copy link

oyiptong commented Mar 1, 2012

i would like to see this implemented as well

@ghost
Copy link

ghost commented Aug 8, 2012

Would love to see this too.

@ryanrolland
Copy link

Thought this might already be possible. Was a bit confused with the docs. Put this stackoverflow post together: http://stackoverflow.com/questions/16474800/elasticsearch-has-child-filter-i-want-to-reference-child-fields-in-results

Seems like the data is already there to build the existing query up. Why not make it available? Would love this feature since it would enable multi-type query integration into UI controls like facetview.

@mvallebr
Copy link

+1 I would like that too

@mattaylor
Copy link

+1 allowing scripts to load other docs by id would be a more usefull general solution here.

@isabel12
Copy link

+1 this would be awesome.

@amerov
Copy link

amerov commented Jul 10, 2014

👍

@cdebry
Copy link

cdebry commented Jul 15, 2014

There is a discussion here that explains the issue in further detail.

This should already be possible using a function score query. The parent / child field can be referenced within the function, but ES doesn't return the value as expected. This seems like a bug rather than a feature.

@clintongormley
Copy link
Contributor

After discussion, we've decided against this issue as looking up another doc from within a script would be prohibitively expensive. Potentially what you need will be solvable when aggregations have parent-child support.

@yehosef
Copy link

yehosef commented Jan 14, 2016

We have this use case - do aggregations have parent/child support now? Are there plans to add it, if not? I could see looking up children would be expensive because there could potentially be many but perhaps it would be possible to have this just for the parent since there can be one.

@yehosef
Copy link

yehosef commented Jan 14, 2016

Also - even if you gave access to the documents in the inner-hits query for scoring or post-filtering it would be great. You're already doing to the lookup for the other documents - you just can't do anything with them in a script (unless I'm missing something..) If you could, that by itself could be very helpful in many use cases.

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

10 participants