Changing Out-Of-The-Box Index Definitions
You may have the need to change an out-of-the-box index definition that is shipped either with oak or any other products built on top of it.
To better deal with upgrades and changes in provided index definitions it would be better to follow the following practice.
Let's say for example that you have the following index definition as
NodeTypeIndex
and you'd like to add your custom node to the list:
cust:unstructured
.
"oak:index/nodetype" : {
"jcr:primaryType": "oak:QueryIndexDefinition",
"declaringNodeTypes": [
"sling:MessageEntry",
"slingevent:Job",
"oak:QueryIndexDefinition",
"rep:User",
"rep:Authorizable",
"sling:bgJobData",
"sling:VanityPath",
"sling:chunks",
"slingevent:TimedEvent",
],
"nodeTypeListDefined": true,
"propertyNames": [
"jcr:primaryType",
"jcr:mixinTypes"
],
"type": "property",
"reindex": false,
"reindexCount": 1
}
to customise it you would do the following:
- Copy the current index definition with a new name. Let's say
oak:index/custNodeType
- Add the custom nodetype to the
declaringNodeTypes
- Issue a re-index by setting
reindex=true
- wait for it to finish
- either disable the old index definition or delete it.
The new index definition in our example, once completed would look like the following:
"oak:index/custNodetype" : {
"jcr:primaryType": "oak:QueryIndexDefinition",
"declaringNodeTypes": [
"sling:MessageEntry",
"slingevent:Job",
"oak:QueryIndexDefinition",
"rep:User",
"rep:Authorizable",
"sling:bgJobData",
"sling:VanityPath",
"sling:chunks",
"slingevent:TimedEvent",
"cust:unstructured"
],
"nodeTypeListDefined": true,
"propertyNames": [
"jcr:primaryType",
"jcr:mixinTypes"
],
"type": "property",
"reindex": false,
"reindexCount": 2
}