Expand my Community achievements bar.

SOLVED

Querbuilder returning results for % in the keyword

Avatar

Level 4

Hi All,

 

We have a requirement we need to search for results with percentage in content for example (97% off or 97%).

 

We are using ootb queryBuilder full text API for this.

But we are getting results which have 97(without %)also in the page.

What needs to be done to exclude such results from showing up in queryBuilder API.

 

We tried with both fulltext=97% and fulltext="97%"(in quotes).

 

For example we only want results which have "97%" as a whole in the page and exlude pages which have "97" in content.

 

Please find the below screenshots for reference for we-retail.

Sb2512_0-1681374331563.png

 

 

 

Page having 97 in the content

 

Sb2512_2-1681374508407.png

 

 

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
5 Replies

Avatar

Employee Advisor

Hi @Sb2512 ,

 

If you know the property field where you need to search then you can form your query like this

 

SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([<path>]) and s.[jcr:title] like '%97%\%'

 

Hope this helps!

 

Regards,

Nitesh

Avatar

Level 4

Can this be done using Query Builder API...We have search results with pagination so query builder seems to be better as it has lot more capabilities for our use case

Avatar

Community Advisor

Hello @Sb2512 ,

If you want to search in the content you may have to write a custom predicate for that.

You will find a similar topic has been discussed in this thread: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/special-characters-search-... 

Thank you

Avatar

Level 4

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

Can writing custom predicate will restrict pages with 97 in the search results.

 

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.

 

 

Sb2512_1-1681386452362.png

 

Sb2512_2-1681386475751.png

 

 

 

Avatar

Correct answer by
Community Advisor

You can read this thread: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/special-characters-search-... 

There you have a complete discussion for requirement.