Skip to content

Commit

Permalink
HSEARCH-3846 Fix automatic recognition of nested filters for sorting …
Browse files Browse the repository at this point in the history
…filters
  • Loading branch information
wklaczynski authored and yrodiere committed Apr 8, 2020
1 parent 6f5354a commit e048837
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -39,6 +39,10 @@ protected Query doBuild(LuceneSearchPredicateContext context) {
}

public static Query doBuild(LuceneSearchPredicateContext parentContext, String nestedDocumentPath, Query nestedQuery) {
if ( nestedDocumentPath.equals( parentContext.getNestedPath() ) ) {
return nestedQuery;
}

BooleanQuery.Builder childQueryBuilder = new BooleanQuery.Builder();
childQueryBuilder.add( Queries.childDocumentQuery(), Occur.FILTER );
childQueryBuilder.add( Queries.nestedDocumentPathQuery( nestedDocumentPath ), Occur.FILTER );
Expand Down
Expand Up @@ -78,11 +78,11 @@ protected Query getLuceneFilter() {

Query luceneFilter = null;
if ( filter instanceof LuceneSearchPredicateBuilder ) {
LuceneSearchPredicateContext filterContext = new LuceneSearchPredicateContext( absoluteFieldPath );
LuceneSearchPredicateContext filterContext = new LuceneSearchPredicateContext( nestedDocumentPath );
luceneFilter = ((LuceneSearchPredicateBuilder) filter).build( filterContext );
}
else {
throw log.unableToCreateNestedSortFilter( absoluteFieldPath );
throw log.unableToCreateNestedSortFilter( nestedDocumentPath );
}

return luceneFilter;
Expand Down

0 comments on commit e048837

Please sign in to comment.