Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Special Characters Search using Querybuilder

sai_kumart66079
Level 2
Level 2

Hi All,

I have a query regarding the search in JCR:content,

1. In the AEM using QueryBuilder. When I try searching with keyword "

KalmKap®" the trademark symbols are not getting searched. Instead of that it is searching for the keyword "Kalmkap".

2. The special characters like "[", "]", "{", "}", and many..... my search is not working...

Below is my Query::

group.1_fulltext.relPath=jcr:content/@jcr:title

group.1_fulltext=[KalmKap]

group.1_fulltext.relPath=jcr:content/@jcr:title

group.1_fulltext=KalmKap®

kindly help me out on this........

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

If you want to do this only with QueryBuilder then create custom predicate

e.g.

Code:

aem63app-repo/CaseInsensitiveLikePredicate.java at master · arunpatidar02/aem63app-repo · GitHub

Query

path=/content/we-retail/us/en/products

caseinsensitive.property=jcr:content/@jcr:title

caseinsensitive.value=%portland®%

Screen Shot 2018-08-20 at 8.21.57 PM.png

View solution in original post

21 Replies
Arun_Patidar
Community Advisor
Community Advisor

Hi,

I am not sure if this is the bug or design issue. But you can try same with SQL2 or QueryBuilder API.

In XPATH you can run like below:

/jcr:root/content/AEM63App/en//*

[

(jcr:contains(., 'KalmKap(®)?'))

]

MeenuRajput
Level 1
Level 1

Hi @Arun_Patidar ,

We're using jcr SQL2 and below mentioned is my query :

SELECT * FROM [cq:PageContent] AS s WHERE ISDESCENDANTNODE([/content/somepath]) AND (CONTAINS(s.[subtitle],"*home-page*") OR CONTAINS(s.[jcr:title],"*home-page*") OR CONTAINS(s.[jcr:description],"*home-page*"))

 

On search of text ("home-page") containing a special character, I get zero results. However, I do have 'home-page' in content nodes as per given conditions.

Could you please help me to correct my query to get results for text having a special character?

 

 

Arun_Patidar
Community Advisor
Community Advisor
Hi, I tried your query , it works with special character, can you share sample string for which it is not working. You can try SELECT * FROM [cq:PageContent] AS s WHERE ISDESCENDANTNODE([/content/somepath]) AND (s.[subtitle] like '%home-page%' OR s.[jcr:title] like '%home-page%' OR s.[jcr:descriptio like '%home-page%')
MeenuRajput
Level 1
Level 1

Hi @Arun_Patidar,

Thanks for your response.

 

I'm not sure how did my shared query work for you. Also, I did try your query, still no results. I'm unable to search any keyword with a special character in between like i-phone, e-niro, e-commerce, mobile-phones whereas all these texts exist in my aem content node in jcr:title/jcr:description which should satisfy conditions in my query and show results on search.

 

Arun_Patidar
Community Advisor
Community Advisor

which version are you using?

I am using 6.5 and it is working for me.

 

Screenshot 2021-02-03 at 21.34.19.png

Veena_Vikram
Community Advisor
Community Advisor

I think you should save the text using hex code for ® symbol. It will be ® .

sai_kumart66079
Level 2
Level 2

No that didn't work.... still my results are KalmKap.

Veena_Vikram
Community Advisor
Community Advisor

Ohk. Will check on this and tell you . Did you try Arun's solution ?

sai_kumart66079
Level 2
Level 2

Tried with Arun's solution... But that didn't work.Arun Patidar

Arun_Patidar
Community Advisor
Community Advisor

Hi Sai,

I gave try for XPATH query again,

works for me.

1. Result with query which you were trying; gives result for both demoText® and demoText

Screen Shot 2018-08-06 at 3.16.17 PM.png

2. Result with below query gives only result which contains at least one ®

Screen Shot 2018-08-06 at 3.16.29 PM.png

If you are not able to get the desire results you can try JAVA API for Search.

Thanks

Arun

Techaspect_Solu
Level 7
Level 7

Hi,

We could achieve your requirement by using the below query. We'd suggest you to give it a try and check if it works.

For trying the below query, go to "/content/we-retail/ca/en/men" and change jcr:title property in title component to "Featured products ®". Then hit the following query from http://localhost:4502/libs/cq/search/content/querydebug.html

path=/content/we-retail/ca/en/men

property=jcr:title

property.operation=like

property.value=%®%

p.limit=-1

You should see the result now.

Hope this helps!

Regards,

TechAspect Solutions

sai_kumart66079
Level 2
Level 2

Hi Arun Patidar

I tried your method, still i'm not getting expected results..

Below without (®)?

1543139_pastedImage_1.png

With (®)?

1543140_pastedImage_2.png

Can you provide reference for JAVA API Search.

Thanks,

Sai.

Arun_Patidar
Community Advisor
Community Advisor

Hi,

Can you try above query suggested by

/jcr:root/content/we-retail/us/en/products//element(*, cq:Page)

[

(jcr:like(jcr:content/@jcr:title, '%Portland®%'))
]

For Java you can either use QueryBuilderAPI or SQL2 queries.

9 JCR-SQL2 Queries Every AEM Developer Should Know - Blog - 6D Global

https://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

http://drfits.com/jcr-sql2-query-with-examples/

Thanks

Arun

sai_kumart66079
Level 2
Level 2

Thanks Techaspect Solutions​, Arun Patidar​...

Using like operator it is working as expected.

Thanks,

Sai.

sai_kumart66079
Level 2
Level 2

Hi Arun,

Using like operator is case sensitive. Please provide any suggestion to make it case insensitive. I tried using

property=fn:lower-case(jcr:content/@jcr:title)

property.value=%kalmkap®%

property.operation=like

but it didn't generate the X-Path in query debugger and no results found.

Any suggestions for using query builder.

cc: Techaspect Solutions

Thanks,

Sai Kumar.

Arun_Patidar
Community Advisor
Community Advisor

Hi,

fn:lower-case is not supported anymore with QueryBuilder.

Though you can use same with Xpath like below.

/jcr:root/content/we-retail/us/en/products//element(*, cq:Page)

[

(jcr:like(fn:lower-case(jcr:content/@jcr:title), '%portland®%'))

]

Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

If you want to do this only with QueryBuilder then create custom predicate

e.g.

Code:

aem63app-repo/CaseInsensitiveLikePredicate.java at master · arunpatidar02/aem63app-repo · GitHub

Query

path=/content/we-retail/us/en/products

caseinsensitive.property=jcr:content/@jcr:title

caseinsensitive.value=%portland®%

Screen Shot 2018-08-20 at 8.21.57 PM.png

View solution in original post

sai_kumart66079
Level 2
Level 2

Thanks Arun Patidar​ The above worked well... I'm able to fetch all the expected results....

Still I'm stuck at one point. How can I limit the search result in XPath, like "guessTotal" in queryBuilder.