Special Characters Search using Querybuilder

Avatar

Avatar

sai_kumart66079

Avatar

sai_kumart66079

sai_kumart66079

02-08-2018

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883
Arun_Patidar
MVP

20-08-2018

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

Answers (16)

Answers (16)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883
Arun_Patidar
MVP

03-08-2018

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

]

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883
Arun_Patidar
MVP

21-08-2018

Hi,

JCR XPATH only support few function, If you want better control over searching and querying the JCR, then use the JCR API SQL2 or the Query Builder

Avatar

Avatar

sai_kumart66079

Avatar

sai_kumart66079

sai_kumart66079

21-08-2018

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.

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

20-08-2018

Nice suggestion and a correct answer

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883
Arun_Patidar
MVP

20-08-2018

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

]

Avatar

Avatar

sai_kumart66079

Avatar

sai_kumart66079

sai_kumart66079

20-08-2018

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

Avatar

sai_kumart66079

Avatar

sai_kumart66079

sai_kumart66079

06-08-2018

Thanks Techaspect Solutions​, Arun Patidar​...

Using like operator it is working as expected.

Thanks,

Sai.

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883
Arun_Patidar
MVP

06-08-2018

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

Avatar

Avatar

sai_kumart66079

Avatar

sai_kumart66079

sai_kumart66079

06-08-2018

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

Avatar

Techaspect_Solu

Avatar

Techaspect_Solu

Techaspect_Solu

06-08-2018

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

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883
Arun_Patidar
MVP

06-08-2018

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

Avatar

Avatar

sai_kumart66079

Avatar

sai_kumart66079

sai_kumart66079

06-08-2018

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

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

06-08-2018

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

Avatar

Avatar

sai_kumart66079

Avatar

sai_kumart66079

sai_kumart66079

06-08-2018

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

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

03-08-2018

Nice suggestion veena!

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

03-08-2018

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