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
-
Assign a tag to the custom index definition in
/oak:index/<index>by specifying thetagsproperty with a custom value. -
Use the
p.indexTagparameter in the Query Builder API query. -
Add
p.indexTag=<tagname>to the query, where<tagname>matches the custom index tag. -
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=coursestype=cq:Pagepath=/content/mysitep.limit=10p.indexTag=customSearch
- Sample Custom Index Definition (under
-
Run the updated query to verify consistent, accurate results with the specified custom index (
customSearch).
Related readings
- Query Builder Predicate Reference in AEMaaCS user guide
- Query Engine processing in Oak Documentation
- Indexing best practices in AEM