querybuilder search on Property case insensitive | Community
Skip to main content
Dterner
Level 2
October 16, 2015
Solved

querybuilder search on Property case insensitive

  • October 16, 2015
  • 11 replies
  • 10019 views

Hi,

I have seen a similar question asked but never found a definitive answer. If I want to query a bunch of nodes for a particular property value using the "like" operation. Is there a way to make that query case insensitive?

appreciate any help.

 

Sample Query  that is case sensitive:

path=/content/project/en type=cq:Page 1_orderby=@jcr:content/date 1_orderby.sort=desc 3_property=jcr:content/cq:template 3_property.value=/apps/project/templates/person 3_property=jcr:content/jcr:title 4_property.1_value = %nameFragment% 4_property.operation = like

Best,

Dmitry

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JustinEd3

Hi Dmitry,

The trick is to lower case the property

4_property=fn:lower-case(jcr:content/jcr:title)

and then lower case the search term

4_property.1_value = %namefragment%

Regards,

Justin

11 replies

smacdonald2008
Level 10
October 16, 2015

When working with the QueryBuilder, it is strongly recommended that you use the QueryBuilder debugger tool. You can perform different tests and see what works and what does not. For more information, see How to Use CQ’s Query Debugger Tool

Dterner
DternerAuthor
Level 2
October 16, 2015

Thanks Scott, the search debugger tool is very helpful and so is the Query Editor that is part of the AEM tools put out by Professional Services. 

The query itself is perfectly fine and produces the required results. However the querying is case sensitive and I would like to ignore case in this instance. Is there a way to achieve this using the querybuilder API? Or does this require a custom predicate? 

If the latter, has anyone seen a similar example in the wild?

JustinEd3Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Hi Dmitry,

The trick is to lower case the property

4_property=fn:lower-case(jcr:content/jcr:title)

and then lower case the search term

4_property.1_value = %namefragment%

Regards,

Justin

Dterner
DternerAuthor
Level 2
October 16, 2015

Thanks Justin, that did the trick.

Feike_Visser1
Adobe Employee
Adobe Employee
June 20, 2018

I don't get this to work in http://localhost:4502/libs/cq/search/content/querydebug.html

Using this:

path=/content/we-retail

type=cq:Page

1_property=fn:lower-case(jcr:content/jcr:title)

1_property.value=english

Adobe Employee
June 22, 2018

yeah it doesn seem to work via property map, though xpath works

/jcr:root/content///element(*, cq:Page)

[(fn:lower-case(jcr:content/@jcr:title) = 'hi') ]

There is additonal support in oak index definitions to run such query optimally by defining function indexes [OAK-3574] Query engine: support p=lowercase('x') and other function-based indexes - ASF JIRA

farahz913310
Level 2
March 13, 2019

Hi ,

I am  trying to  add the fn:lower-case(jcr:content/jcr:title) in my querybuilder code in my servlet  but lowercase function doesnt work.

When QueryBuilder creates a Xpath query it resolves to below :

fn:lower-case_x0028__x0040_jcr:content/@boxTitle_x0029_

Has anyone faced this issue?

Adobe Employee
March 13, 2019

farahz913310​ Based on the discussion in Re: AEM 6.2 "fn:lowercase" is not working   (and some other linked threads), it appears that the function described in my original "correct" answer (from 2015) stopped working with AEM 6.2 and was never officially supported. That thread has a proposed solution which does (apparently) work in 6.2 and beyond.

farahz913310
Level 2
March 13, 2019

Thanks @justin.

As mentioned here Re: AEM 6.2  "fn:lowercase"  is not working ,So the better solution is use SQL2 instead of Xpath query ?

Adobe Employee
March 13, 2019

As I understand it, the issue is not really XPath vs. SQL2, but really with the QueryBuilder. But you might want to ask in the other thread to be sure.