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

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

Closed

Conversation

martijnvg
Copy link
Member

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 Parent/child: has_child or other p/c query wrapped in a query filter may emit wrong results Parent/Child: has_child or other p/c query wrapped in a query filter may emit wrong results Sep 11, 2014
@s1monw
Copy link
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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

:) will do

…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes elastic#7685
martijnvg added a commit that referenced this pull request Sep 12, 2014
…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
…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
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes #7685
@martijnvg martijnvg deleted the bug/pc-wrapped-query-filter branch May 18, 2015 23:30
@clintongormley clintongormley changed the title Parent/Child: has_child or other p/c query wrapped in a query filter may emit wrong results 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
…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
…QueryWrappingFilter must always be used and any filter wrapping the query filter must never be cached.

Closes elastic#7685
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Parent/Child labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v1.3.3 v1.4.0.Beta1 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants