Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7.1 - Filtering search results by specific custom field
In LR 6.2 I could filter the results by modifying the search context this way:
searchContext.setKeywords(keywords + " AND expando/custom_fields/region:" + myRegion);
In ElasticSearch custom fields are named differently, but this doesn't work (returns no results):
searchContext.setKeywords(keywords + " AND expando__custom_fields__region:" + myRegion);
How this kind of filter can be accomplished? (I am customizing the User Admin search code).
For searching by expandos, maybe try something similar to this?
https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-search/portal-search-test-util/src/main/java/com/liferay/portal/search/test/util/expando/BaseExpandoTestCase.java#L303
Hey Amos,
I just checked your link -- very cool! Is that something that is new to 7.1?
Andrew,
I'm not sure, I just found it myself while looking for something else :)
Hi Jan,
Usually when I I want to accomplish something like this I would use the setBooleanClauses() method on teh search context, rather than changing the keywords that the user entered. It's still working with the searchContext (as you are right now) but you would do something like ..
BooleanClause expandoClause = BooleanClauseFactoryUtil.create(<expando field name>, <your value>,BooleanClauseOccur.MUST.toString()); searchContext.setBooleanClauses(new BooleanClause[]{expandoClause});
That usually works for me.
Powered by Liferay™