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

A `has_child` or other p/c query wrapped in a query filter may emit wrong results #7685

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@martijnvg
Member

martijnvg commented Sep 11, 2014

If a has_child, has_parent or top_children is indirectly wrapped in a query filter (for example via a bool query) then the results are incorrect. This bug manifests in all places in the dsl where query filter can be used.

This PR lets the query filter use the CustomQueryWrappingFilter class if the query being wrapped in a query filter indirectly uses a p/c query. (the case when p/c query was directly being wrapped was already covered).

Also if a query filter is wrapping a p/c query (either directly or indirectly) any filter wrapping it if forcefully never cached. Caching this would also lead to wrong results, since the p/c queries can't be cached per segment, while regular filter can.

@clintongormley clintongormley changed the title from Parent/child: has_child or other p/c query wrapped in a query filter may emit wrong results to Parent/Child: has_child or other p/c query wrapped in a query filter may emit wrong results Sep 11, 2014

@s1monw

This comment has been minimized.

Contributor

s1monw commented Sep 12, 2014

LGTM

@@ -151,8 +152,8 @@ public static Filter wrap(Query query) {
// and potentially miss a forbidden API usage!
private static final class QueryWrapperFilterFactory {
public Filter wrap(Query query) {
if (CustomQueryWrappingFilter.shouldUseCustomQueryWrappingFilter(query)) {
public Filter wrap(Query query, QueryParseContext context) {

This comment has been minimized.

@s1monw

s1monw Sep 12, 2014

Contributor

@martijnvg I think you should take the time to add some javadocs to this :) please but feel free to push anyway

This comment has been minimized.

@martijnvg

martijnvg Sep 12, 2014

Member

:) will do

Parent/child: If a p/c query is wrapped in a query filter then Custom…
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes #7685

martijnvg added a commit that referenced this pull request Sep 12, 2014

Parent/child: If a p/c query is wrapped in a query filter then Custom…
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes #7685

martijnvg added a commit that referenced this pull request Sep 12, 2014

Parent/child: If a p/c query is wrapped in a query filter then Custom…
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes #7685

@martijnvg martijnvg closed this in 91144fc Sep 12, 2014

martijnvg added a commit that referenced this pull request Sep 12, 2014

Parent/child: If a p/c query is wrapped in a query filter then Custom…
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes #7685

@martijnvg martijnvg deleted the martijnvg:bug/pc-wrapped-query-filter branch May 18, 2015

@clintongormley clintongormley changed the title from Parent/Child: has_child or other p/c query wrapped in a query filter may emit wrong results to A `has_child` or other p/c query wrapped in a query filter may emit wrong results Jun 7, 2015

mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015

Parent/child: If a p/c query is wrapped in a query filter then Custom…
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes elastic#7685

mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015

Parent/child: If a p/c query is wrapped in a query filter then Custom…
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes elastic#7685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment