We want our results from content to be returned in this order
how should we go about ensuring URL is included as first search criteria?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @aembytes
In order for URL to be first in the Search Results, we need to boost nodeName in the respective index (that is used for fulltext query execution)
Example:
For a full text query like below, cqPageLucene is used.
path=/content/we-retail fulltext=Skitouring type=cq:Page p.limit=-1
In order to have URLs that contain Skitouring to be rendered first than the jcr:title for instance, update the cqPageLucene as below and reindex.
Explain Query response:
Query Results:
Just for a cross check I have amended the title of "Experience" page to Skitouring (which we see as a result in 4th entry)
Suggest to check which index is used for your fulltext query execution(as evident by Explain Query) and boost nodeName and other properties of that index accordingly.
Update: Per official doc, boost should be of type "Double". (Screenshots from my local is when I used String and it works too)
Hi @aembytes ,
You can create custom predicates for that. You can use orderBy predicate with desired property and can join the results. Also, you can boost a specific property and give desired value to have order in place.
https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md
Hi @aembytes
In order for URL to be first in the Search Results, we need to boost nodeName in the respective index (that is used for fulltext query execution)
Example:
For a full text query like below, cqPageLucene is used.
path=/content/we-retail fulltext=Skitouring type=cq:Page p.limit=-1
In order to have URLs that contain Skitouring to be rendered first than the jcr:title for instance, update the cqPageLucene as below and reindex.
Explain Query response:
Query Results:
Just for a cross check I have amended the title of "Experience" page to Skitouring (which we see as a result in 4th entry)
Suggest to check which index is used for your fulltext query execution(as evident by Explain Query) and boost nodeName and other properties of that index accordingly.
Update: Per official doc, boost should be of type "Double". (Screenshots from my local is when I used String and it works too)
One additional query, what you mentioned worked, so that's awesome. If I had to put a page with the highest occurrence of search word on the top, would that be OOB behavior in jcr:score ordering or I'll have to do that additionally with a different attribute etc?
Thanks for the confirmation @aembytes
It happens OOTB. For fulltext index, search results are sorted by jcr:score descending (result with highest score being the first) by default.
If you would like to cross check this, you can print the jcr:score as part of query results and observe the behaviour.
Using the same example :
select [jcr:path], [jcr:score] from [cq:Page] as a where contains(*, 'Skitouring') and isdescendantnode(a, '/content/we-retail')
Result:
Only thing to note is that if you have union of fulltext queries, scoring is applied for each subquery individually and hence the ultimate result won't be ordered by score in this case.
Views
Likes
Replies