Hi,
I have the below tagmanger getting results for a component.
Is it possible to create oak index for the below??
code:-
import com.day.cq.tagging.*;
final TagManager tagManager = getResource().getResourceResolver().adaptTo(TagManager.class);
final List<String[]> allTags = Arrays.asList(dcTags, abcTags);
Iterator<Resource> results = tagManager.find(serachPath, allTags)
oak index generate url:-
https://oakutils.appspot.com/generate/index
Regards,
Srinivas
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @srinivas_chann1,
TagManager.find method will generate XPath query like below - it can be a bit different depending on basePath and list of tags. In this example following input has been used:
/jcr:root/content//element(*, cq:Taggable)[ (@cq:tags = 'we-retail:activity/hiking' or @cq:tags = '/content/cq:tags/we-retail/activity/hiking') and (@cq:tags = 'we-retail:activity/biking' or @cq:tags = '/content/cq:tags/we-retail/activity/biking') ] order by @jcr:score descending
You can see XPath query in the logs. To do this add additional logger on DEBUG level that will log com.day.cq.tagging.impl
Checking above query using AEM build in Query Performance tool, it can be seen that ntBaseLucene(/oak:index/ntBaseLucene) is used.
I think before you will decide to create custom index I would suggest to do some performance test to check if currently used will not be enough.
Knowing how the query looks and answering your question. Yes it is possible to generate index for query used by find method from TagManager, below is an example. However please remember to use custom index only if OOTB is not fully covering your use case.
<?xml version="1.0" encoding="UTF-8"?><jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"> <myIndex compatVersion="{Long}2" async="async" jcr:primaryType="oak:QueryIndexDefinition" evaluatePathRestrictions="{Boolean}true" type="lucene"> <indexRules jcr:primaryType="nt:unstructured"> <cq:Taggable jcr:primaryType="nt:unstructured"> <properties jcr:primaryType="nt:unstructured"> <tags name="cq:tags" propertyIndex="{Boolean}true" jcr:primaryType="nt:unstructured"/> </properties> </cq:Taggable> </indexRules> </myIndex> </jcr:root>
Hi @srinivas_chann1,
TagManager.find method will generate XPath query like below - it can be a bit different depending on basePath and list of tags. In this example following input has been used:
/jcr:root/content//element(*, cq:Taggable)[ (@cq:tags = 'we-retail:activity/hiking' or @cq:tags = '/content/cq:tags/we-retail/activity/hiking') and (@cq:tags = 'we-retail:activity/biking' or @cq:tags = '/content/cq:tags/we-retail/activity/biking') ] order by @jcr:score descending
You can see XPath query in the logs. To do this add additional logger on DEBUG level that will log com.day.cq.tagging.impl
Checking above query using AEM build in Query Performance tool, it can be seen that ntBaseLucene(/oak:index/ntBaseLucene) is used.
I think before you will decide to create custom index I would suggest to do some performance test to check if currently used will not be enough.
Knowing how the query looks and answering your question. Yes it is possible to generate index for query used by find method from TagManager, below is an example. However please remember to use custom index only if OOTB is not fully covering your use case.
<?xml version="1.0" encoding="UTF-8"?><jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"> <myIndex compatVersion="{Long}2" async="async" jcr:primaryType="oak:QueryIndexDefinition" evaluatePathRestrictions="{Boolean}true" type="lucene"> <indexRules jcr:primaryType="nt:unstructured"> <cq:Taggable jcr:primaryType="nt:unstructured"> <properties jcr:primaryType="nt:unstructured"> <tags name="cq:tags" propertyIndex="{Boolean}true" jcr:primaryType="nt:unstructured"/> </properties> </cq:Taggable> </indexRules> </myIndex> </jcr:root>
Views
Likes
Replies
Views
Like
Replies