Skip to main content
srinivas_chann1
Level 7
May 30, 2022
Solved

oak indexing on aem 6.5 with nt base

  • May 30, 2022
  • 1 reply
  • 640 views

Hi,

We have an xpath query for xml addon with the below  and want to create a new oak index

 

/jcr:root/content/app/us/en/productguide_Product_Reference_Guide//*[(jcr:contains(., 'battery'))] order by @6655266:score descending

 

I checked on https://oakutils.appspot.com/generate/index  

 

It showed the below . 

<?xml version="1.0" encoding="UTF-8"?><jcr:root xmlns:nt=http://www.jcp.org/jcr/nt/1.0 xmlns:jcr=http://www.jcp.org/jcr/1.0>

  <myIndex compatVersion="{Long}2" async="async" jcr:primaryType="oak:QueryIndexDefinition" evaluatePathRestrictions="{Boolean}true" type="lucene">

    <indexRules jcr:primaryType="nt:unstructured">

      <nt:base jcr:primaryType="nt:unstructured">

        <properties jcr:primaryType="nt:unstructured"/>

      </nt:base>

    </indexRules>

  </myIndex>

</jcr:root>

 

Is it good practice  to index the nt base like above without any named properties .Please suggest what could be alternative.

 

Note:- we are using the Adobe provided xml addon OOTB .

 

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 DEBAL_DAS

If the following value battery(as mentioned in your query) is associated with any property and specific node type then you can use Explain query [http://localhost:7070/libs/granite/operations/content/diagnosistools/queryPerformance.html] to compare query performance between "/jcr:root/content/app/us/en/productguide_Product_Reference_Guide//*[(jcr:contains(., 'battery'))] order by @jcr:score descending" and the query with named property, specific node [/jcr:root/content/we-retail/language-masters//element(*,cq:PageContent)[@sling:resourceType="weretail/components/structure/page"] order by @6655266:score].

 

I feel it will help you optimize your query and finally you will be able to create requisite oak indexing.

 

Personally I always follow below points while writing any query -

  • Whenever possible, use CONTAINS instead of LIKE or '='. It should be your default choice when you need to find a specific text.
  • If a query seems to be slow, check its execution plan using Diagnosis Tool.
  • If you need more specific restrictions, use both CONTAINS and LIKE/equals.
  • Use a specific location.
  • Use a specific node type.

Please refer this : https://wttech.blog/blog/2020/jcr-query-performance/

1 reply

DEBAL_DAS
DEBAL_DASAccepted solution
New Member
May 30, 2022

If the following value battery(as mentioned in your query) is associated with any property and specific node type then you can use Explain query [http://localhost:7070/libs/granite/operations/content/diagnosistools/queryPerformance.html] to compare query performance between "/jcr:root/content/app/us/en/productguide_Product_Reference_Guide//*[(jcr:contains(., 'battery'))] order by @jcr:score descending" and the query with named property, specific node [/jcr:root/content/we-retail/language-masters//element(*,cq:PageContent)[@sling:resourceType="weretail/components/structure/page"] order by @6655266:score].

 

I feel it will help you optimize your query and finally you will be able to create requisite oak indexing.

 

Personally I always follow below points while writing any query -

  • Whenever possible, use CONTAINS instead of LIKE or '='. It should be your default choice when you need to find a specific text.
  • If a query seems to be slow, check its execution plan using Diagnosis Tool.
  • If you need more specific restrictions, use both CONTAINS and LIKE/equals.
  • Use a specific location.
  • Use a specific node type.

Please refer this : https://wttech.blog/blog/2020/jcr-query-performance/

Debal Das, Senior AEM Consultant