[hibernate-issues] [JIRA] (HSEARCH-3889) Exception Predicate targets unexpected fields when use nested() in sort filter

Waldemar Kłaczyński (JIRA) jira at hibernate.atlassian.net
Sat Apr 11 17:30:07 EDT 2020


Waldemar Kłaczyński ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A77e50cac-bda3-4af4-9bb3-6461f4d10eea ) *commented* on HSEARCH-3889 ( https://hibernate.atlassian.net/browse/HSEARCH-3889?atlOrigin=eyJpIjoiMGQ0NWEzMmJlN2RmNDMyNmIxZWZiY2JlM2JhNGMzNDMiLCJwIjoiaiJ9 )

Re: Exception Predicate targets unexpected fields when use nested() in sort filter ( https://hibernate.atlassian.net/browse/HSEARCH-3889?atlOrigin=eyJpIjoiMGQ0NWEzMmJlN2RmNDMyNmIxZWZiY2JlM2JhNGMzNDMiLCJwIjoiaiJ9 )

This has to do with the "AbstractLuceneNestablePredicateBuilder.checkNestableWithin" function. For nested queries for which nesting is the same as the nesting value, this check should not be performed. Check only when required. To fix this error is to swap "#checkNestableWithin" in the "#build" function.

diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/AbstractLuceneNestablePredicateBuilder.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/AbstractLuceneNestablePredicateBuilder.java
index d6624fa..f502e67 100644
--- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/AbstractLuceneNestablePredicateBuilder.java
+++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/AbstractLuceneNestablePredicateBuilder.java
@@ -33,8 +33,6 @@

	@Override
	public final Query build(LuceneSearchPredicateContext context) {
-		checkNestableWithin( context.getNestedPath() );
-
		List<String> nestedPathHierarchy = getNestedPathHierarchy();
		String expectedNestedPath = nestedPathHierarchy.isEmpty() ? null
				: nestedPathHierarchy.get( nestedPathHierarchy.size() - 1 );
@@ -44,6 +42,8 @@
			return super.build( context );
		}

+		checkNestableWithin( context.getNestedPath() );
+
		// The context we expect this predicate to be built in.
		// We'll make sure to wrap it in nested predicates as appropriate in the next few lines,
		// so that the Query is actually executed in this context.

( https://hibernate.atlassian.net/browse/HSEARCH-3889#add-comment?atlOrigin=eyJpIjoiMGQ0NWEzMmJlN2RmNDMyNmIxZWZiY2JlM2JhNGMzNDMiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-3889#add-comment?atlOrigin=eyJpIjoiMGQ0NWEzMmJlN2RmNDMyNmIxZWZiY2JlM2JhNGMzNDMiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200411/b7e61dbc/attachment.html 


More information about the hibernate-issues mailing list