Oak Queries and Indexing

Introduction

Unlike Jackrabbit 2, Oak does not index content by default. Custom indexes need to be created when necessary, much like with traditional relational databases. If there is no index for a specific query then the whole repository will be traversed. The query will still work but probably be very slow. 

If Oak encounters a query without an index, a WARN level log message is printed:

*WARN* Traversed 1000 nodes with filter Filter(query=select ...) consider creating an index or changing the query
        

Code-Beispiele dienen lediglich zu Illustrationszwecken.

Supported query languages

The Oak query engine supports the following languages:

  • XPath
  • SQL
  • SQL-2
  • JQOM

Indexer types

The new Apache Oak based backend allows different indexers to be “plugged into” the repository.

The standard indexer is the Property Index, for which the index definition is stored in the repository itself.

External full text indexers can also be used with AEM. Implementations for Apache Lucene and Solr are available by default.

The Traversal Index indexer is the one used if no other indexer is available. This means that the content is not indexed and all content nodes are traversed to find matches to the query.

If multiple indexers are available for a query, each available indexer estimates the cost of executing the query. Oak then chooses the indexer with the lowest estimated cost.

Configuring indexes

Indexes are configured as nodes in the repository. All the indexes will be configured under the oak:index node.

The Property Index

You can add a Property Index by following the below procedure:

  1. Open CRXDE by going to http://localhost:4502/crx/de/index.jsp

  2. Create a new node under oak:index

  3. Name the node according to its purpose, and set the node type to oak:QueryIndexDefinition

  4. Add the following properties to the node:

    • name: type with the value of property
    • propertyNames with the value of the properties that need to be stored in the index
  5. Save the node.

​