creating oak index for tagmanager aem6,5 | Community
Skip to main content
srinivas_chann1
Level 7
June 30, 2022
Solved

creating oak index for tagmanager aem6,5

  • June 30, 2022
  • 1 reply
  • 697 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

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:

  • basePath = /content
  • tagIDs = we-retail:activity/hiking, we-retail:activity/biking
/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>

 

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
June 30, 2022

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:

  • basePath = /content
  • tagIDs = we-retail:activity/hiking, we-retail:activity/biking
/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>