DocumentationAEMAEM TutorialsAEM Sites Tutorials

Simple search implementation guide

Last update: March 23, 2025
  • Applies to:
  • Experience Manager 6.4
  • Experience Manager 6.5
  • Topics:
  • Search

CREATED FOR:

  • Intermediate
  • Experienced
  • Developer

The Simple search implementation are the materials from the Adobe Summit lab AEM Search Demystified. This page contains the materials from this lab. For a guided tour of the lab, please view the Lab workbook in the Presentation section of this page.

Search Architecture Overview

Presentation materials

  • Lab workbook
  • Presentation

Bookmarks

Tools

  • Index Manager
  • Explain Query
  • CRXDE Lite > /oak:index/cqPageLucene
  • CRX Package Manager
  • QueryBuilder Debugger
  • Oak Index Definition Generator

Chapters

The Chapter links below assume the Initial Packages are installed on AEM Author at http://localhost:4502

  • Chapter 1
  • Chapter 2
  • Chapter 3
  • Chapter 4
  • Chapter 5
  • Chapter 6
  • Chapter 7
  • Chapter 8
  • Chapter 9

Packages

Initial packages

  • Tags
  • Simple search application package

Chapter packages

  • Chapter 1 solution
  • Chapter 2 solution
  • Chapter 3 solution
  • Chapter 4 solution
  • Chapter 5 setup
  • Chapter 5 solution
  • Chapter 6 solution
  • Chapter 9 solution

Referenced materials

  • Github repository
  • Sling Models
  • Sling Model Exporter
  • QueryBuilder API
  • AEM Chrome Plug-in (Documentation page)

Corrections and Follow-up

Corrections and clarifications from the lab discussions and answers to follow-up questions from attendees.

  1. How to stop re-indexing?

    Re-indexing can be stopped via the IndexStats MBean available via AEM Web Console > JMX

    • http://localhost:4502/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3Dasync%2Ctype%3DIndexStats

      • Execute abortAndPause() to abort the re-indexing. This will lock the index to further re-indexing until resume() is invoked.
      • Executing resume() will restart the indexing process.
    • Documentation: https://jackrabbit.apache.org/oak/docs/query/indexing.html#async-index-mbean

  2. How can oak indexes support multiple tenants?

    Oak supports placing indexes through-out the content tree, and these indexes will only index within that sub-tree. For example /content/site-a/oak:index/cqPageLucene could be create to index content only under /content/site-a.

    An equivalent approach is to use the includePaths and queryPaths properties on an index under /oak:index. For example:

    • /oak:index/siteAcqPageLucene@includePaths=/content/site-a
    • /oak:index/siteAcqPageLucene@queryPaths=/content/site-a

    The considerations with this approach are:

    • Queries MUST specify a path restriction that is equal to the index’s query path scope, or be a descendant there of.
    • Broader scoped indexes (for example /oak:index/cqPageLucene) will ALSO index the data, resulting in duplicative-ingestion and disk use cost.
    • May require duplicative configuration management (ex. adding the same indexRules across multiple tenant indexes if they must satisfy the same query sets)
    • This approach is best served on the AEM Publish tier for custom site search, as on AEM Author, it is common for queries to be executed at high up the content tree for different tenants (for example, via OmniSearch) - different index definitions can result in different behavior based only on the path restriction.
  3. Where is a list of all available Analyzers?

    Oak exposes a set of lucene-provides analyzer configuration elements for use in AEM.

    • Apache Oak Analyzers documentation

      • Tokenizers
      • Filters
      • CharFilters
  4. How to search for Pages and Assets in the same query?

    New in AEM 6.3 is the ability to query for multiple node-types in the same provided query. The following QueryBuilder query. Note that each “sub-query” can resolve to its own index, so in this example, the cq:Page sub-query resolves to /oak:index/cqPageLucene and the dam:Asset sub-query resolves to /oak:index/damAssetLucene.

    group.p.or=true
    group.1_group.type=cq:Page
    # add all page restrictions to this group
    group.2_group.type=dam:Asset
    # add all asset restrictions to this group
    

    results in the following query and query plan:

    QUERY:(//element(*, cq:Page) | //element(*, dam:Asset))
    
    PLAN: [cq:Page] as [a] /* lucene:cqPageLucene(/oak:index/cqPageLucene) *:* */ union [dam:Asset] as [a] /* lucene:damAssetLucene(/oak:index/damAssetLucene) *:* */
    

    Explore the query and results via QueryBuilder Debugger and AEM Chrome Plug-in.

  5. How to search over multiple paths in the same query?

    New in AEM 6.3 is the ability to query across multiple paths in the same provided query. The following QueryBuilder query. Note that each “sub-query” may resolve to its own index.

    
    group.p.or=true
    group.1_group.type=cq:Page
    group.1_group.path=/content/docs/en/6-2
    # add all page restrictions to this group
    group.2_group.type=cq:Page
    group.2_group.path=/content/docs/en/6-3
    # add all asset restrictions to this group
    

    results in the following query and query plan

    
    QUERY: (/jcr:root/content/docs/en/_x0036_-2//element(*, cq:Page) | /jcr:root/content/docs/en/_x0036_-3//element(*, cq:Page))
    
    PLAN: [cq:Page] as [a] /* traverse "/content/docs/en/6-2//*" where isdescendantnode([a], [/content/docs/en/6-2]) */ union [cq:Page] as [a] /* traverse "/content/docs/en/6-3//*" where isdescendantnode([a], [/content/docs/en/6-3]) */
    

    Explore the query and results via QueryBuilder Debugger and AEM Chrome Plug-in.

recommendation-more-help
bb44cebf-d964-4e3c-b64e-ce882243fe4d