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
BedrockMission!

Learn More

View all

Sign in to view all badges

AEM 6.5 Search Suggestion

Avatar

Avatar
Boost 1
Level 1
berkayf70599426
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Level 1
berkayf70599426
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
berkayf70599426
Level 1

12-08-2020

Hi,

I implement a custom search suggestion servlet. In servlet i use query like this "SELECT [rep:suggest()] FROM [cq:Page] WHERE SUGGEST('tes') AND (ISDESCENDANTNODE('/content/myproject/tr'))".

 

In advance, i need to add template filter to results. So far i tried to add another where clause like [jcr:content/cq:template] <> '/conf/myproject/settings/wcm/templates/experience-fragment-web-variation-template'  but that didn't work, query return 0 result. Then tried to exlude path that contains unwanted pages like this NOT ISDESCENDANTNODE('content/myproject/tr/somepath') that also didn't work. Do you guys have any suggestions for how to achieve what i want to do ? 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 1
Level 1
berkayf70599426
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Level 1
berkayf70599426
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
berkayf70599426
Level 1

12-08-2020

Thanks for answers, I already modified cqPageLucene index for suggestion purposes and mostly it works fine. My queries return results e.g this query returns 3 nodes "SELECT [rep:suggest()] FROM [cq:Page] WHERE SUGGEST('tes') AND (ISDESCENDANTNODE('/content/myproject/tr'))". When i checked results only 1 page's template is correct. Whenever i try to add another where clause like "AND NOT ISDESCENDANTNODE('/content/myproject/tr/unwantedpath'))" or "AND [jcr:content/cq:template] <> 'some-template-name' " there is always no result returns.

As far as i understand, only  ISDESCENDANTNODE clause can be used with SUGGEST(), other constraints are not allowed to use in SUGGEST(), am i right ?

Answers (4)

Answers (4)

Avatar

Avatar
Give Back 3
Level 4
SundeepKatepally
Level 4

Likes

76 likes

Total Posts

76 posts

Correct Reply

21 solutions
Top badges earned
Give Back 3
Boost 10
Boost 25
Boost 50
Affirm 10
View profile

Avatar
Give Back 3
Level 4
SundeepKatepally
Level 4

Likes

76 likes

Total Posts

76 posts

Correct Reply

21 solutions
Top badges earned
Give Back 3
Boost 10
Boost 25
Boost 50
Affirm 10
View profile
SundeepKatepally
Level 4

12-08-2020

In suggestion there is a drawback. What happens is first it brings the top 10 results(before executing template condition) and then it will apply your template condition , So what happens is on the top 10 suggestion results from path /content/myproject/tr, if it has any record matching your template condition then it will return. Looks like your getting 0 results as top 10 records are not matching with template condition.

 

We have same issue in our project hence we started using typical query builder query and not suggestion,

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

505 likes

Total Posts

641 posts

Correct Reply

213 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

505 likes

Total Posts

641 posts

Correct Reply

213 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile
Vijayalakshmi_S
MVP

12-08-2020

Hi @berkayf70599426,

Jackrabbit Oak supports search suggestions when using Lucene/Solr Index. 

Given this understanding, your query should be using cqPageLucene index - /oak:index/cqPageLucene 

For suggestion to work, 

  • "useInSuggest" should be set to true. (OOB cqPageLucene has this for properties jcrTitle and jcrDescription, navTitle, pageTitle, nodeName)
    • /oak:index/cqPageLucene/indexRules/cq:Page/properties/jcrTitle
    • /oak:index/cqPageLucene/indexRules/cq:Page/properties/jcrDescription
  • Support for path check via "ISDESCENDANTNODE" is introduced since Oak 1.3.16/1.2.14 (Oak version of AEM 6.2 is 1.4.1. So should be available in all recent versions)
    • To respect ISDESCENDANTNODE, evaluatePathRestrictions should be set to true in index definition. (which is available in OOB cqPageLucene)

Suggestion Results:

  • Suggestion results are top 10 filtered suggestions from Indexed content(will always be <= 10 and not greater than 10).
  • Below query will return suggestion results only if any of the filtered suggestions are part of the path (mentioned in ISDESCENDANTNODE). Otherwise it will be 0.
  • In other words, It is not like "get all the suggestions under the path 'content/myproject/tr' ". Suggestions are returned/evaluated and then path is respected.  
    • SELECT [rep:suggest()] FROM [cq:Page] WHERE SUGGEST('tes') AND (ISDESCENDANTNODE('/content/myproject/tr'))"

Now for debugging, I suggest you to

  • Cross check all the above and then
  • Execute the query in "Explain Query" (Tools -> Operations -> Diagnosis -> Query Performance -> Explain Query - Check "Include Node Count") without path restriction first - SELECT [rep:suggest()] FROM [cq:Page] WHERE SUGGEST('tes') and then observe the behavior with path.

Play around in your local instance with different suggest term/ paths to arrive at an above understanding

Avatar

Avatar
Give Back
Level 2
narendragandhi
Level 2

Likes

17 likes

Total Posts

14 posts

Correct Reply

6 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Give Back
Level 2
narendragandhi
Level 2

Likes

17 likes

Total Posts

14 posts

Correct Reply

6 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 10
Boost 1
View profile
narendragandhi
Level 2

12-08-2020

Hi @berkayf70599426 ,

 

To implement suggestions you would need to also have the required index created. Please refer the below link for how your index definition should look like -

 

https://jackrabbit.apache.org/oak/docs/query/lucene.html#suggestions

 

Avatar

Avatar
Give Back 50
Employee
berliant
Employee

Likes

207 likes

Total Posts

315 posts

Correct Reply

98 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
berliant
Employee

Likes

207 likes

Total Posts

315 posts

Correct Reply

98 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
berliant
Employee

12-08-2020

You can try a query similar to:

fulltext=English
path=/content/we-retail

group.p.or=true
group.1_group.type=cq:Page


group.2_group.property=jcr:content/cq:template
group.2_group.property.value=/conf/we-retail/settings/wcm/templates/hero-page
p.limit=-1

 

And test it in Querry builder Debbuger: http://localhost:4502/libs/cq/search/content/querydebug.html

 

You can translate it to SQL syntax by evaluating it in Query Explanation tool at http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html