Ordered Index (deprecated since 1.1.8)
Extension of the Property index will keep the order of the indexed property persisted in the repository.
Used to speed-up queries with ORDER BY clause, equality and range ones.
SELECT * FROM [nt:base] ORDER BY jcr:lastModified
SELECT * FROM [nt:base] WHERE jcr:lastModified > $date
SELECT * FROM [nt:base] WHERE jcr:lastModified < $date
SELECT * FROM [nt:base]
WHERE jcr:lastModified > $date1 AND jcr:lastModified < $date2
SELECT * FROM [nt:base] WHERE [jcr:uuid] = $id
To define a property index on a subtree you have to add an index definition node that:
- must be of type oak:QueryIndexDefinition
- must have the type property set to ordered
- contains the propertyNames property that indicates what properties will be stored in the index. propertyNames has to be a single value list of type Name[]
Optionally you can specify
- the reindex flag which when set to true, triggers a full content re-index.
- The direction of the sorting by specifying a direction property of type String of value ascending or descending. If not provided ascending is the default.
- The index can be defined as asynchronous by providing the property async=async
Caveats
- In case deploying on the index on a clustered mongodb you have to define it as asynchronous by providing async=async in the index definition. This is to avoid cluster merges.