We have created custom index on oak:index for different sites/markets in our repository. In each index defintion, we have added queryPath ( /content/xyz/us,/content/dam/xyz/us) so that when we search in US site, only the custom index is picked up.
When we do a search only on one type either cq:page or dam:asset type, XPATH query is building properly with the path and our Custom Index definition is picked up and results are coming up fine.
However when we do a search on both cq:Page & dam:Asset at the same time using group predicate, XPATH query is building differently( on content root) and due to this OOTB index definition is picking up and search is happening..
What we want is to have our custom index picked up for above Query. Could anyone let us know how to achieve this? Thanks.
Are these answers useful? Help other community members by marking useful answers as accepted.
When we search only for content pages or assets using below syntax, we are able to get the results using our custom index (After adding queryPaths in the index definition we are able to get our custom index).
And below is the XPATH query built when we hit with above syntax. ( here search is happening on the below given path with our custom index)
and for DAM search, below is the XPATH query and results are coming from custom index.
You can't select which index is going to be used for query, its based on cost of execution.
But If you can switch to native queries then only it is possible
Native Query and Index Selection
Oak query engine supports native queries like
//*[rep:native('lucene', 'name:(Hello OR World)')]
If multiple Lucene based indexes are enabled on the system and you need to make use of specific Lucene index like /oak:index/assetIndex then you can specify the index name via functionName attribute on index definition.
For example for assetIndex definition like
jcr:primaryType = “oak:QueryIndexDefinition”
type = “lucene” …
functionName = “lucene-assetIndex”
Executing following query would ensure that Lucene index from assetIndex should be used
//*[rep:native('lucene-assetIndex', 'name:(Hello OR World)')]