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 ?
Solved! Go to Solution.
Views
Replies
Total Likes
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 ?
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
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
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,
Suggestion Results:
Now for debugging, I suggest you to
Play around in your local instance with different suggest term/ paths to arrive at an above understanding
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,
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 ?
Hi @berkayf70599426,
There is no explicit mention in the official documentation about the support of other clause.
However, given the fact that ISDESCENDANTNODE support is included as an enhancement/update to suggestion + from the way suggestion results work, it makes sense to conclude that it supports one ISDESCENDANTNODE alone.
Views
Replies
Total Likes