Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

AEM - SQL Query with function based indexing for LOWER

Avatar

Adobe Champion

I have a query as below

 

SELECT * FROM [dam:Asset] AS a WHERE ISDESCENDANTNODE(a,[/content/dam/company/creative-assets/opt/campaigns]) AND LOWER(a.[jcr:path]) LIKE '%/100098282_enfr%' ORDER BY a.[jcr:created]

 

We have created a custom index and created the required index properties including the one for function indexing as below.

P_V_Nair_0-1653064838797.png

 

This has been re-indexed as well.

 

Now when we run the above query, query tool gives 0 results with the LOWER function in it 

and when i remove the lower function as below, I get 1 result as below.

SELECT * FROM [dam:Asset] AS a WHERE ISDESCENDANTNODE(a,[/content/dam/company/creative-assets/opt/campaigns]) AND a.[jcr:path] LIKE '%/100098282_enfr%' ORDER BY a.[jcr:created]

Result as:

/content/dam/company/creative-assets/opt/campaigns/2022/100098282_enfr.jpg

 

Since we need to handle case sensitive scenarios as well here like ENFR, EnFr etc. we need lower in the query.

 

Can someone help me understand why I get 0 results when I add LOWER function to my query and how to fix this issue?

@lukasz-m @Arun_Patidar @Raja-kp @kautuk_sahni @Nupur_Jain 

1 Accepted Solution

Avatar

Correct answer by
Adobe Champion

This issue got fixed after using the right function index value in the index. I have updated the screenshot for reference. I had to use fn:lower(@jcr:path) in the index property and that fixed the issue.

View solution in original post

2 Replies

Avatar

Correct answer by
Adobe Champion

This issue got fixed after using the right function index value in the index. I have updated the screenshot for reference. I had to use fn:lower(@jcr:path) in the index property and that fixed the issue.

Avatar

Employee Advisor

Here you could see I have created similar folder hierarchy and uploaded one jpg with similar name -

DEBAL_DAS_0-1653069468776.png

 

Query with LOWER function is giving me result -

 

DEBAL_DAS_1-1653069570965.png

 

Could you please test your query using Tools--> Operations--> Diagnosis-->Query Performance --> Explain Query as shown below -

DEBAL_DAS_3-1653069860977.png

 

DEBAL_DAS_2-1653069731680.png

Tested on AEM 6.5.9