问题
Please suggest on how to implement case insensitive search using querybuilder in CQ5. My code is as below ...
paramMap.put("1_property", searchType);
paramMap.put("1_property.value", "%" + searchString + "%");
paramMap.put("1_property.operation", "like");
paramMap.put("2_property", "documentId");
paramMap.put("2_property.operation", "exists");
paramMap.put("3_orderby.sort", "asc");
paramMap.put("p.limit", "0");
searchType is the node property searchString is the string that needs to be matched
Presently, it does a case sensitive search. I tried the solution mentioned here http://www.wemblog.com/2013/04/how-to-create-custom-query-predicate-in.html It didnt work out.
回答1:
I have faced the same question and found 3 possible solutions for case-insensitive search using QueryBuilder:
Custom query predicate you mentioned above.
fulltext predicate.
Disadvantage: it's greedy and will find all %your_search_query% matches.
Details is here: http://maxbarrass.blogspot.com/2014/05/jcr-predicate-operations-in-aem.htmlnodename predicate.
This is workaround and works only if you are searching for jcr:title property because in most cases nodename = lowercased and escaped jcr:title.
So, you can search for nodename instead of jcr:title property.
Third approach was good for me.
回答2:
With AEM 6.2 (and I think a FP for 6.1) querybuilder now supports case insensitive sorting via orderby.case=ignore
.
回答3:
@alex order.case is for ordering results...
@Ignat and @David 4th option uing Xpath :)
/jcr:root/etc/tags//element(*, cq:Tag)
[
(jcr:like(fn:lower-case(@jcr:title), '%projects%'))
]
来源:https://stackoverflow.com/questions/28878727/case-insensitive-search-in-cq5-using-querybuilder