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

Query Regarding Full Text Search

binoyp
Level 2
Level 2

Hi All,

 

Is there any way to make use of non english words like "español" as fulltext in Querybuilder  API?

1 Accepted Solution
ChitraMadan
Correct answer by
Community Advisor
Community Advisor

Hi @binoyp,

 

Full text search will be able to find español in the content irrespective of language. Please see below OOTB groovy script which is able to find all the references of español in the content

 

def predicates = [
"path": "/content",
"fulltext": "español"
]

def query = createQuery(predicates)

query.hitsPerPage = 10

def result = query.result

println "${result.totalMatches} hits, execution time = ${result.executionTime}s\n--"

result.hits.each { hit ->
println "hit path = ${hit.node.path}"
}

 

Please check if UTF-8 is enabled in Apache Sling Request Parameter Handling configuration.

View solution in original post

4 Replies
Singaiah_Chintalapudi
Community Advisor
Community Advisor

The QueryBuilder works on the given predicates. If you're using non-english words and searching in those specific locales, it should work. For example: searching "español" in /content/yourproject/es/*.

 

What problem are you facing or whats the requirement?

 

Thanks,

Singaiah

binoyp
Level 2
Level 2
Hi Singaiah, the exact doubt is that when i try passing the fulltext as a parameter in a querybuilder servlet for searching the pages. These special characters throw a bad request error . How can we work around this.
Singaiah_Chintalapudi
Community Advisor
Community Advisor
also, whats version of AEM are you on? You first make sure you get the right input before passing that to QueryBuilder API? Also manually query using the same string and see if you get results.
ChitraMadan
Correct answer by
Community Advisor
Community Advisor

Hi @binoyp,

 

Full text search will be able to find español in the content irrespective of language. Please see below OOTB groovy script which is able to find all the references of español in the content

 

def predicates = [
"path": "/content",
"fulltext": "español"
]

def query = createQuery(predicates)

query.hitsPerPage = 10

def result = query.result

println "${result.totalMatches} hits, execution time = ${result.executionTime}s\n--"

result.hits.each { hit ->
println "hit path = ${hit.node.path}"
}

 

Please check if UTF-8 is enabled in Apache Sling Request Parameter Handling configuration.

View solution in original post

binoyp
Level 2
Level 2
Hi Chitra, the exact doubt is that when i try passing the fulltext as a parameter in a querybuilder servlet for searching the pages. These special characters throw a bad request error . How can we work around this.
ChitraMadan
Community Advisor
Community Advisor
Hi @binoyp, Can you please check if UTF-8 is enabled in Apache Sling Request Parameter Handling configuration.
binoyp
Level 2
Level 2
Hi Chitra, ive chcked for the UTF settings , it is enabled. One observation i made is that it seems to be working on a new custom path that im registering it on. For the existing path's it seems to be throwing a bad request error at the ajax call. I've tried encodeURI and encodeURIComponent for encoding the fulltext term. That doesnt help as well