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
Expose matching nested docs to the query and sort #1383
Comments
+1 for this. We're having to do additional post processing on the result set to try and "guess" which of the nested documents matched so we can show relevant matches to our users. Being able to return just the matched nested documents (and be able to sort on them) would be a massive win. Thanks, |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 as well (assuming this hasn't been added yet) |
+1, any news about this ? |
+1 opens up a lot of use-cases. A big general one: given a product / product-variant mapping -> return only the matched product-variant |
As for a more concrete example: the following (pretty general imho) usecase would be possible. |
+1 |
2 similar comments
+1 |
+1 |
I'm closing this one. Nested sorting has been implemented and I created an issue for retrieving the matching nested inner objects per hit #3022 |
+1 for this. |
@evandu, if you're looking for nested filtering, read this: http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/ If you're looking for nested sorting, read this: http://www.elasticsearch.org/guide/reference/api/search/sort/ (nested sorting is down the page a little bit) |
Hiya
I have a use case for nested docs which, currently, can not be supported easily.
For instance, have a look at this doc:
contexts
andtokens
are both nested docs.I would like to run query like:
contexts.context == '/de'
contexts.context.rank desc
contexts.label.short asc
but of course I have no way of pulling out the single matching context and using the values in that sub-doc.
I could use a script sort like the horribly inefficient:
Or I may want to do:
context=='/de'
stein*
tokens
that match best as a fieldOr have a slightly different doc structure:
and return the
label
associated with thetokens
that best match.Even with a script, I couldn't find the best matching
tokens
.In this example, I only have two contexts, and so could have changed the doc structure to something like:
But I have other use cases where I have hundreds of contexts, which would result in thousands of fields.
Would it be possible to add functionality to:
expose the best matching child (or children, with the best matching first in an array) in a
_scope
so we could do something like:"sort": [
{ "_child.myscope[0].rank": "desc" },
{ "_child.myscope[0].label.short": "asc"}
],
"fields": [ "_child.otherscope[0],tokens.label" ]
return the scores for matching children in a
_scope
eg:{ "children":
{
"myscope": [5,3,0,2,0],
"otherscope": [0,1,0]
}
}
Not sure how feasible this is, and if it is feasible, there is probably a much more elegant way of doing it.
thanks
clint
The text was updated successfully, but these errors were encountered: