Expand my Community achievements bar.

SOLVED

Query Builder with Multiple Paths - Sort Order Seems Incorrect

Avatar

Level 1

I am grouping 2 paths for a query, and the results that come back always display results from the first path first, then followed by the second path, regardless of the jcr:score.

My goal is to have combined results, sorted by jcr:score.

Results always come back in this way, with results ordered by jcr:score within the path. Can the results come back so the results are only based on score?

Results:
path1 score: 10
path1 score: 5
path1 score: 1
path2 score: 9
path2 score: 6
path2 score: 3
path2 score 1

Desired:
path1 score: 10

path2 score: 9

path2 score: 6

path1 score: 5
path2: score: 3

path1: score 1

path2: score 1

This is my actual query:

 

fulltext=searchterm
group.0_path=/content/section1
group.0_path.self=true
group.1_path=/content/section2
group.1_path.self=true
group.p.or=true
orderby=@jcr:score
orderby.sort=desc
property=jcr:content/excludeFromSearch
property.operation=not
2_property=jcr:content/cq:redirectTarget
2_property.operation=not
type=cq:Page
p.limit=-1
p.excerpt=true
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @HN_Doug 

Can you remove the "group.p.or=true" parameter and add the "orderby=@jcr:score" parameter outside of the grouping block and verify

fulltext=searchterm
group.0_path=/content/section1
group.0_path.self=true
group.1_path=/content/section2
group.1_path.self=true
orderby=@jcr:score
orderby.sort=desc
property=jcr:content/excludeFromSearch
property.operation=not
2_property=jcr:content/cq:redirectTarget
2_property.operation=not
type=cq:Page
p.limit=-1
p.excerpt=true

 

 

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi @HN_Doug 

Can you remove the "group.p.or=true" parameter and add the "orderby=@jcr:score" parameter outside of the grouping block and verify

fulltext=searchterm
group.0_path=/content/section1
group.0_path.self=true
group.1_path=/content/section2
group.1_path.self=true
orderby=@jcr:score
orderby.sort=desc
property=jcr:content/excludeFromSearch
property.operation=not
2_property=jcr:content/cq:redirectTarget
2_property.operation=not
type=cq:Page
p.limit=-1
p.excerpt=true

 

 

Avatar

Level 1

without group.p.or=true, I had zero results. adding that back in fixed it. Otherwise, it's working as needed. Thank you.

Avatar

Level 1

Using that same query you provided, how could I override the cq:redirectTarget NOT condition if another, new page property was checked?

For example, if I add a property named jcr:content/featuredSearch that could be checked:

If jcr:content/featuredSearch is checked, add the page to the results even if it has something in jcr:content/cq:redirectTarget