Expand my Community achievements bar.

SOLVED

Special Characters Search using Querybuilder

Avatar

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

Avatar

Correct answer by
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



Arun Patidar

View solution in original post

24 Replies

Avatar

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(®)?'))

]



Arun Patidar

Avatar

Level 3

Hi @arunpatidar ,

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?

 

 

Avatar

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%')


Arun Patidar

Avatar

Level 3

Hi @arunpatidar,

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.

 

Avatar

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



Arun Patidar

Avatar

Community Advisor

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

Avatar

Level 2

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

Avatar

Community Advisor

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

Avatar

Level 2

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

Avatar

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



Arun Patidar

Avatar

Level 4

@arunpatidar  Is there any way  for when we search for demoText® Search we get only pages which have demoText® and not demoText.

 

As right now it shows for both demoText® and demoText.

 

I need to get the pages with only demoText® when i searched for demoText®.

 

Avatar

Community Advisor

You can try using like operator.



Arun Patidar

Avatar

Level 4

@arunpatidar 

 

For us ,we will have full text content search not a property search.

 

 

Sb2512_0-1681386386329.png

 

 

 

 

 

One Page has 97 and one page has 97%.

 

I want to restrict Page with "97" to be shown in the search results when i search with fulltext=97%.

 

I just want the search results which have 97% in the page not 97.

 

 

Sb2512_1-1681386452362.png

 

Sb2512_2-1681386475751.png

Can this be done with Fulltext search

 

 

Avatar

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

Avatar

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.

Avatar

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



Arun Patidar

Avatar

Level 2

Thanks Techaspect Solutions​, Arun Patidar​...

Using like operator it is working as expected.

Thanks,

Sai.

Avatar

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.

Avatar

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