Lucene index, CustomScoreQuery. AEM6.3
Hi,
I have a query that finds all pages and all pdf files in specific paths using QueryBuilder and lucene index. The PDF part is not currently relevant for the question.
I would like to have number property on each page node, lets call it "luceneScoreModifier" that will alter the calculate the jcr:score. The property value should be multiplied into the calculate jcr:score to boost the page up in result.
I have found something calles CustomScoreQuery with CustomScoreProvide that could help my needs
Examples with ScorerProvider - org.apache.jackrabbit.oak.plugins.index.lucene.score.ScorerProvider
But unfortunetely i do not know how to use it with QueryBuilder.
Do You know how my goal can be achieved or point me to the right direction ??
For the records here is my predicateGroup and xpath for the query.
Map<String, String> map = new HashMap<String, String>();
map.put("fulltext" , fulltextSearchTerm);
map.put("orderby" , "@jcr:score");
map.put("orderby.sort" , "desc");
map.put("group.p.or", "true");
map.put("group.1_group.type", "cq:Page");
map.put("group.1_group.path", rootSitePath);
map.put("group.1_group.property" , "jcr:content/index");
map.put("group.1_group.property.operation" , JcrPropertyPredicateEvaluator.OP_EXISTS);
map.put("group.1_group.property.value" , "false");
map.put("group.2_group.type", "dam:Asset");
map.put("group.2_group.path", rootAssetPath);
map.put("group.2_group.property" , "jcr:content/metadata/dc:format");
map.put("group.2_group.property.value" , "application/pdf");
PredicateGroup.create(map);
Xpath
/jcr:root/content/siteName//element(*, cq:Page)[(not(jcr:content/@index)) and (jcr:contains(., 'test'))] | /jcr:root/content/dam/siteName//element(*, dam:Asset)[(jcr:content/metadata/@dc:format = 'application/pdf') and (jcr:contains(., 'test'))]) order by @jcr:score descending