Inconsistent query results in AEM Query Builder API

In Adobe Experience Manager (AEM), executing a query with the Query Builder API returns inconsistent results if an unintended index is used. To fix, specify the desired index using an index tag in the Query Builder API.

Description description

Environment

  • Product: AEM Managed Services, Sites ,v6.5
  • Instance: Production

Issue/Symptoms

Query results are inconsistent when an unintended index is used during query execution.

Resolution resolution

To fix this issue, follow these steps

  1. Assign a tag to the custom index definition in /oak:index/<index> by specifying the tags property with a custom value.

  2. Use the p.indexTag parameter in the Query Builder API query.

  3. Add p.indexTag=<tagname> to the query, where <tagname> matches the custom index tag.

  4. Verify the query uses the intended custom index. For example:

    • Sample Custom Index Definition (under /oak:index/fullTextSearch): jcr:mixinTypes="[ rep:AccessControllable] "
      async="[ async,nrt] "
      compatVersion="{Long}2"
      evaluatePathRestrictions="{Boolean}true"
      excludedPaths="[ /var,/etc/replication,/etc/workflow/instances,/jcr:system] "
      includedPaths="[ /content/mysite] "
      queryPaths="[ /content/mysite] "
      reindex="{Boolean}false"
      reindexCount="{Long}1"
      seed="{Long}-4788584413483415353"
      type="lucene"
      tags="[ customSearch] "
    • XPath Query using a specific index: /jcr:root/content/data/element(*, cq:Page)[ (jcr:contains(., 'courses'))] option (index tag customSearch)
    • Equivalent Query Builder API Query: fulltext=courses
      type=cq:Page
      path=/content/mysite
      p.limit=10
      p.indexTag=customSearch
  5. Run the updated query to verify consistent, accurate results with the specified custom index (customSearch).

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f