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
How to make a nested query to filter when searching by a ddmFieldArray elem
Hi!
I want to make a boolean query that gets the value of a field of a structure called "isFinal" that has "YES" and "NO" as values, and filter the Journal Articles according to this.
I had the following code for achieving that, but I am not introducing the value "YES" (which is the one I want to filter) anywhere, how can I make it?
//This is the principal query
BooleanQuery booleanQuery = queries.booleanQuery();
//Here starts the code for the nested one
BooleanQuery boolQueryForNested = queries.booleanQuery();
TermQuery termQuery = queries.term("ddmFieldArray.ddmFieldName", "ddm__keyword__" + prestacionStructure.getStructureId() + "__isFinal_es_ES");
boolQueryForNested.addFilterQueryClauses(termQuery);
NestedQuery nestedQuery = queries.nested("ddmFieldArray", boolQueryForNested);
booleanQuery.addMustNotQueryClauses(nestedQuery);
Thank you in advance!
Hello Maria Z,
The solution is to use a BooleanQuery with TermQuery to search for specific values within these nested fields. For example, you can target fields like ddmFieldArray.ddmFieldName and ddmFieldArray.ddmFieldValueKeyword_en_US
To know more: https://www.surekhatech.com/blog/create-a-nested-query-to-filter-searches-by-ddmfieldarray-element-in-liferay
Powered by Liferay™