Case insensitive search in CQ5 using querybuilder

一世执手 提交于 2019-12-24 03:07:05

问题


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:

  1. Custom query predicate you mentioned above.

  2. 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.html

  3. nodename 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!