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
Enforce _parent field resolution to be strict #9521
Conversation
Should it reuse |
Yes, reusing is better than introducing a new setting. The Perhaps |
+1 to reuse, the use-case looks very similar to me. We could think about renaming it to something more generic in the future. |
+1 I'll do that in a different issue. Also I think we should have the same behaviour for the |
I'm not sure about this change. Why can't we just say: if there is no defined _parent, return no docs for that index/type? It'd be the equivalent of ignoring documents that don't have a mapping for the field we're searching on. |
@clintongormley Whether we return no documents depends on how the has_child/has_parent get used in the query dsl (e.g. boolean should vs. boolean must clause), but I see what you mean... Actually the behaviour I'm after is similar to the |
I think there are use-cases for both. When you have a well-defined schema, it can be desirable that anything that targets a field that is not in the schema is rejected. So somehow I wish we had a single parameter that would help fail in such cases as well as when a referenced _parent does not exists like Martijn proposes? |
@jpountz isn't this the |
@jpountz @clintongormley What about adding Not specifying the This will work a bit different than how the |
@martijnvg The idea sounds reasonable, but we already have lots of parameters that apply to queries (names, boosts, etc.) and I'd like to only add new options if they have strong use-cases. I think it would already be great progress to have a single per-request flag that allows to control whether to be lenient in terms of unmapped fields (including missing parents). |
@jpountz That is a valid concern, so lets start by adding a top level field to the search api called |
+1. I would also rather use the values |
@rjernst I like those values, but just wondering about the |
@martijnvg Yes, that was my intention with having it there. |
@rjernst Cool, that makes sense to me too. So what I plan to do is remove the Then in a followup issue/PR I'll this top level |
…ild` and `has_parent` filters.
A type defined in a has_child query must have a _parent field. A type defined in a has_parent query must have child type with a _parent field pointing to it. Closes elastic#9461
dd5c63c
to
0b05ac8
Compare
strict
option that controls how to deal with no or incorrectly configured _parent field mapping.
Closing this PR as it is no longer relevant. (#12016) |
A type defined in a has_child query must have a _parent field.
A type defined in a has_parent query must have child type with a _parent field pointing to it.
PR fixes #9461 too. The query parsing failed sometimes with a unexpected NPE, because the
_parent
field is pointing to a non existing type. The consistent strict _parent field resolution makes sure the NPE can't occur any more.This PR also includes a commit that removes the old and used
_cache
and_cache_key
options. (master only)