Sie sehen sich Hilfeinhalte der folgenden Version an:
- 6.5
- 6.4
- 6.3
- 6.2
- Ältere Versionen
Hinweis:
This article is about configuring indexes in AEM 6. For best practices on optimizing query and indexing performance, see Best Practices for Queries and Indexing.
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
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.

The above diagram is a high level representation of the query execution mechanism of Apache Oak.
First, the query is parsed into an Abstract Syntax Tree. Then, the query is checked and transformed into SQL-2 which is the native language for Oak queries.
Next, each index is consulted to estimate the cost for the query. Once that is completed, the results from the cheapest index are retrieved. Finally, the results are filtered, both to ensure that the current user has read access to the result and that the result matches the complete query.
Indexes are configured as nodes in the repository under the oak:index node.
The type of the index node must be oak:QueryIndexDefinition. Several configuration options are available for each indexer as node properties. For more information, see the configuration details for each indexer type below.
The Property Index is generally useful for queries that have property constraints but are not full-text. It can be configured by following the below procedure:
The Property Index has the following configuration options:
- The type property will specify the type of index, and in this case it must be set to property
- The propertyNames property indicates the list of the properties that will be stored in the index. In case it is missing, the node name will be used as a property name reference value. In this example, the jcr:uuid property whose job is to expose the unique identifier (UUID) of its node is added to the index.
- The unique flag which, if set to true adds a uniqueness constraint on the property index.
- The declaringNodeTypes propery allows you to specify a certain node type that the index will only apply to.
- The reindex flag which if set to true, will trigger a full content reindex.
The Ordered index is an extension of the Property index. It keeps the order of the indexed property persistent in the repository.
It is used to speed up queries with "ORDER BY", equality and range clauses.
Like the Property Index, it can be configured by following the below procedure:
The following configuration options are available for the Ordered index:
- The type property for the Ordered index must be set to ordered
- The propertyNames property will specify what properties will be stored in the index. It has to be a simple value list of type Name.
- The reindex flag which if set to true, will trigger a full content re-index.
- The direction of the sorting can be configured, by adding the direction property. It can have a value of ascending or descending. If not configured, the default will be ascending.
- The index can be defind as asynchronous by setting the async property to async.
Hinweis:
In case the index is deployed on a clustered MongoDB setup, you have to define it as asynchronous by providing async=async in the index definition. This is needed in order to avoid cluster merges.
A full text indexer based on Apache Lucene is available in AEM 6.
If a full-text index is configured, then all queries that have a full-text condition use the full-text index, no matter if there are other conditions that are indexed, and no matter if there is a path restriction.
If no full-text index is configured, then queries with full-text conditions may not work as expected. The query engine has a basic verification in place for full-text conditions, but it does not support all features that Lucene does and it will traverse all nodes if there are no indexed constraints.
Because the index is updated via an asynchronbous background thread, some full-text searches will be unavailable for a small window of time until the background processes are finished.
You can configure a Lucene full-text index, by following the below procedure:
The Lucene Index has the following configuration options:
- The type property which will specify the type of index must be set to lucene
- The async property which must be set to async. This will send the index update process to a background thread.
- The includePropertyTypes property, which will define what subset of property types will be included in the index.
- The excludePropertyNames property which will define a blacklist of property names - properties that should be excluded from the index.
- The reindex flag which when set to true, triggers a full content re-index.
Since Oak 1.0.8, Lucene can be used to create indexes which involve property constraints that are not full-text.
In order to achieve a Lucene Property Index the fulltextEnabled property must always be set to false.
Take the following example query:
select * from [nt:base] where [alias] = '/admin'
In order to define a Lucene Property Index for the above query, you can add the following definition by creating a new node under oak:index:
- Name: LucenePropertyIndex
- Type: oak:QueryIndexDefinition
Once the node has been created, add the following properties:
- type: lucene (of type String)
- async: async (of type String)
- fulltextEnabled: false (of type Boolean)
- includePropertyNames: ["alias"] (of type String)
Hinweis:
Compared to the regular Property Index, the Lucene Property Index is always configured in async mode. Thus, the results returned by index may not always reflect the most up to date state of the repository.
Hinweis:
For more specific information on the Lucene Property Index, see the Apache Jackrabbit Oak Lucene documentation page.
Since version 1.2.0, Oak supports Lucene analyzers.
Analyzers are used both when a document is indexed, and at query time. An analyzer examines the text of fields and generates a token stream. Lucene analyzers are composed of a series of tokenizer and filter classes.
The analyzers can be configured via the analyzers node (of type nt:unstructured) inside the oak:index definition.
The default analyzer for an index is configured in the default child of the analyzers node.

Hinweis:
For a list of available analyzers, please consult the API documentation of the Lucene version you are using.
-
Add a property to the default node with the following properties:
- Name: class
- Type: String
- Value: org.apache.lucene.analysis.standard.StandardAnalyzer
The value is the name of the analyzer class you wish to use.
You can also set the analyzer to be used with a specific lucene version by using the optional luceneMatchVersion string propery. A valid synthax for using it with Lucene 4.7 would be:
- Name: luceneMatchVersion
- Type: String
- Value: LUCENE_47
If luceneMatchVersion is not provided, Oak will use the version of Lucene it is shipped with.
Analyzers can also be composed based on Tokenizers, TokenFilters and CharFilters. You can do this by specifying an analyzer and creating children nodes of its optional tokenizers and filters which will be applied in listed order.
Consider this node structure as an example:
- Name: analyzers
- Name: default
- Name: charFilters
- Type: nt:unstructured
- Name: HTMLStrip
- Name: Mapping
- Name: tokenizer
- Property Name: name
- Type: String
- Value: Standard
- Property Name: name
- Name: filters
- Type: nt:unstructured
- Name: LowerCase
- Name: Stop
- Property name: words
- Type: String
- Value: stop1.txt, stop2.txt
- Name: stop1.txt
- Type: nt:file
- Name: stop2.txt
- Type: nt:file
- Property name: words
- Name: default
The name of the filters, charFilters and tokenizers are formed by removing the factory suffixes. Thus:
- org.apache.lucene.analysis.standard.StandardTokenizerFactory becomes standard
- org.apache.lucene.analysis.charfilter.MappingCharFilterFactory becomes Mapping
- org.apache.lucene.analysis.core.StopFilterFactory becomes Stop
Any configuration parameter required for the factory is specified as property of the the node in question.
For cases such as loading stop words where content from external files needs to be loaded, the content can be provided by creating a child node of nt:file type for the file in question.
The purpose of the Solr index is mainly full-text search but it can also be used to index search by path, property restrictions and primary type restrictions. This means the Solr index in Oak can be used for any type of JCR query.
The integration in AEM happens at the repository level so that Solr is one of the possible indexes that can be used in Oak, the new repository implementation shipped with AEM.
It can be configured to work as an embedded server with the AEM instance, or as a remote server.
AEM can be used with an embedded Solr server that can be configured via the Web Console. In this case, the Solr server will run in the same JVM as the AEM instance it is embedded to.
You can configure the embedded Solr server by:
-
Next, edit "Oak Solr embedded server configuration" and create a configuration. For more info on the configuration options, please visit the Apache Solr website.
Hinweis:
The Solr home directory (solr.home.path) configuration will look for a folder with the same name in the AEM installation folder.
-
Download and extract the latest version of Solr. For more info on how to do this, please consult the Apache Solr Installation documentation.
-
Hinweis:
For more info on Solr and ZooKeeper configuration, consult the Solr Configuration documentation and the ZooKeeper Getting Started Guide.
Below is an example of a base configuration that can be used with all three SOLR deployments described in this article. It accomodates the dedicated property indexes that are already present in AEM and should not be used with other applications.
In order to properly use it, you need to place the contents of the archive directly in the Solr Home Directory. In the case of multi-node deployments, it should go directly under the root folder of each node.
Herunterladen
AEM 6.1 also integrates two indexing tools present in AEM 6.0 as part of the Adobe Consulting Services Commons toolset:
- Explain Query, a tool designed to help administrators understand how queries are executed;
- Oak Index Manager, a Web User Interface for maintaining existing indexes.
You can now reach them by going to Tools - Operations - Dashboard - Diagnosis from the AEM Welcome screen.
For more information on how to use them, see the Operations Dashboard documentation.
The ACS Commons package also exposes OSGi configurations that can be used to create property indexes.
You can access it from the Web Console by searching for "Ensure Oak Property Index".

Situations may arise where queries take a long time to execute, and the general system response time is slow.
This section presents a set of recommendations on what needs to be done in order to track down the cause of such issues and advice on how to resolve them.
The easiest way to get required information for the query being executed is via the Explain Query tool. This will enable you to collect the precise information that is needed to debug a slow query without the need to consult the log level information. This is desirable if you know the query that is being debugged.
If this is not possible for any reason, you can gather the indexing logs in a single file and use it to troubleshoot your particular problem.
To enable logging, you need to enable DEBUG level logs for the categories pertaining to Oak indexing and queries. These categories are:
- org.apache.jackrabbit.oak.plugins.index
- org.apache.jackrabbit.oak.query
- com.day.cq.search
The com.day.cq.search category is only applicable if you are using the AEM provided QueryBuilder utility.
Hinweis:
It is important that the logs are only set to DEBUG for the duration the query you want to troubleshoot is being executed, otherwise a large amount of events will be generated in the logs over time. Because of this, once the required logs are collected switch back to INFO level logging for the categories mentioned above.
The way the query gets evaluated is largely affected by the index configuration. It is important to get the index configuration in order to be analyzed or sent to support. You can either get the configuration as a content package or get a JSON rendition.
Since in most cases, the indexing configuration is stored under the /oak:index node in CRXDE, you can get the JSON version at:
http://serveraddress:port/oak:index.tidy.-1.json
If the index is configured at a different location, change the path accordingly.
In some cases it is helpful to provide the output of index related MBeans for debugging. You can do this by:
You can also get the JSON variant of these statistics at the following URLs:
- http://serveraddress:port/system/sling/monitoring/mbeans/org/apache/jackrabbit/oak/%2522LuceneIndex%2522.tidy.-1.json
- http://serveraddress:port/system/sling/monitoring/mbeans/org/apache/jackrabbit/oak/%2522LuceneIndex%2522.tidy.-1.json
- http://serveraddress:port/system/sling/monitoring/mbeans/org/apache/jackrabbit/oak/%2522LuceneIndex%2522.tidy.-1.json
- http://serveraddress:port/system/sling/monitoring/mbeans/org/apache/jackrabbit/oak/%2522LuceneIndex%2522.tidy.-1.json
You can also provide consolidated JMX output via http://serveraddress:port/system/sling/monitoring/mbeans/org/apache/jackrabbit/oak.tidy.3.json. This would include all Oak related MBean details in JSON format.
You can gather additional details in order to help troubleshoot the problem, such as:
- The Oak version your instance is running on. You can see this by opening CRXDE and looking at the version in the lower right corner of the welcome page, or by checking the version of the org.apache.jackrabbit.oak-core bundle.
- The QueryBuilder Debugger output of the troublesome query. The debugger can be accessed at: http://serveraddress:port/libs/cq/search/content/querydebug.html