Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Searching in specific order

Avatar

Level 4

We want our results from content to be returned in this order

 

  • URL contains <keyword/>
  • Page title contains <keyword/>
  • Tags contain <keyword/>
  • Page Description (will crawl all source metadata)  contains <keyword/>
  • Boost frequency <keyword/> to the top

 

how should we go about ensuring URL is included as first search criteria?

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

Vijayalakshmi_S_0-1630434346873.png

Vijayalakshmi_S_1-1630434408271.png

Explain Query response:

Vijayalakshmi_S_2-1630434540278.png

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)

Vijayalakshmi_S_3-1630434628507.png

 

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)

View solution in original post

4 Replies

Avatar

Community Advisor

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://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-fulltext-search-result...

https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md

 

Avatar

Correct answer by
Community Advisor

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.

Vijayalakshmi_S_0-1630434346873.png

Vijayalakshmi_S_1-1630434408271.png

Explain Query response:

Vijayalakshmi_S_2-1630434540278.png

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)

Vijayalakshmi_S_3-1630434628507.png

 

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)

Avatar

Level 4

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?

 

 

Avatar

Community Advisor

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:

  • results are returned with highest score being the top. 
  • experience page has the term "Skitouring" only in jcr:title and hence the least score.

Vijayalakshmi_S_0-1630891841762.png

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.