Waldemar Kłaczyński (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HSEARCH-3889 (
https://hibernate.atlassian.net/browse/HSEARCH-3889?atlOrigin=eyJpIjoiYmI...
)
Re: Exception Predicate targets unexpected fields when use nested() in sort filter (
https://hibernate.atlassian.net/browse/HSEARCH-3889?atlOrigin=eyJpIjoiYmI...
)
I know you can do that. But then you need to submit the filter for sorting and searching
separately. The idea is to use the same filtering query and not worry about how to use it
when sorting and searching differently. This is important for very complex filters, where
it is necessary to use the nesting predicate once and in other cases it should not be
used. PR should be able to adapt himself. Do not throw exceptions, require some complex
actions.
I know you can do that. But then you need to submit the filter for sorting and searching
separately. The idea is to use the same filtering query and not worry about how to use it
when sorting and searching differently. This is important for very complex filters, where
it is necessary to use the nesting predicate once and in other cases it should not be
used. PR should be able to adapt himself. Do not throw exceptions, require some complex
actions.
PermissionQuery allowQuery = new PermissionQuery( "prices.permissions" ,
operation, user, true );
filter = createComplexFilter(...);
sort.add(sorter.field( "prices.bruttoPrice_sort" )
.asc()
.mode(SortMode.MIN)
.filter(filter));
SearchQuery<Assortment> query = session.search(scope)
.where((f) -> f.bool().must(select)
.filter(filter)
.sort(sort.toSort())
.toQuery();
.....
public static SearchPredicate createComplexFilter(...) {
PermissionQuery allowQuery = new PermissionQuery( "prices.prmissions"
, "share" , user, true );
PermissionQuery dannyQuery = new PermissionQuery( "prices.prmissions"
, "share" , user, false );
BooleanQuery query = new BooleanQuery.Builder()
.add(allowQuery, BooleanClause.Occur.MUST)
.add(dannyQuery, BooleanClause.Occur.MUST_NOT)
.build();
SearchPredicate permfilter = predicate
.nested().objectField( "prices" )
.nest(predicate
.extension(LuceneExtension.get())
.fromLuceneQuery(query))
.toPredicate();
SearchPredicate activefilter = ctx.predicate()
.match().field( "prices.active" )
.matching( true )
.toPredicate();
SearchPredicate filter = predicate.bool()
.must(activefilter)
.must(permfilter)
.toPredicate();
return filter;
}
In this case it would not be possible. My patch makes it possible. Just when building a
query, it decides by context how to build a filter.
(
https://hibernate.atlassian.net/browse/HSEARCH-3889#add-comment?atlOrigin...
) Add Comment (
https://hibernate.atlassian.net/browse/HSEARCH-3889#add-comment?atlOrigin...
)
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....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )