Expand my Community achievements bar.

Restricting oak index unique contraint by path

Avatar

Level 4

I have an oak property index (oak:QueryIndexDefinition) applied to a property. On the index, “unique” is set to true – to apply a uniqueness constraint to that particular property. Is it possible to restrict this constraint only to certain sections of the repository?

 

I know there’s a index property declaringNodeTypes which can be used to restrict the constraint only to certain node types. But is there a way to restrict by path rather than type?

 

I tried adding the properties includedPaths and exludedPaths to the index but to no avail.

 

Any help here will be much appreciated. Thanks!

3 Replies

Avatar

Level 4

In the included paths.. I have set the path as “/content/abc/reports”. But in the logs, when I reindex that particular property index, I see it’s traversing a different set of nodes:

 

20.04.2016 19:51:58.726 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing would be performed for following indexes [/oak:index/gir:documentGuid]

20.04.2016 19:51:58.750 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #10000 /jcr:system/jcr:versionStorage/8a/f7/a3

20.04.2016 19:51:58.767 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #20000 /jcr:system/jcr:versionStorage/7a/76/4e/abcd/1.0/jcr:frozenNode/jcr:content/renditions/original

20.04.2016 19:51:58.783 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #30000 /etc/workflow/instances/2016-04-20/model_339098627412981/history/1461137942465/workItem

20.04.2016 19:51:58.814 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #40000 /etc/workflow/instances/2016-04-20/model_339172364070573/history/1461137340572

20.04.2016 19:51:58.828 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #50000 /etc/workflow/instances/2016-04-20/model_339118266984211/data/payload

20.04.2016 19:51:58.842 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #60000 /etc/workflow/instances/2016-04-20/model_338772748426406/history/1461136373511

20.04.2016 19:51:58.860 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #70000 /etc/workflow/instances/2016-04-20_1/model_339280694120062/history/1461137983214/workItem

20.04.2016 19:51:58.876 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #80000 /etc/workflow/instances/2016-04-20_1/model_339245522598263/data

20.04.2016 19:51:58.891 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #90000 /etc/workflow/instances/2016-04-20_1/model_339278397140139/history/1461137838773

20.04.2016 19:51:58.906 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #100000 /etc/workflow/instances/2016-04-20_1/model_339237493105688/history/1461137677978/workItem

20.04.2016 19:51:58.921 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #110000 /etc/clientlibs/granite/coralui/js/components/CUI.FileUpload.MimeTypes.js/jcr:content

20.04.2016 19:51:58.937 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #120000 /content/dam/research/en/multimedia/2016/01/10/erff/1.0/document_pdf.pdf/jcr:content/renditions/cq5dam.thumbnail.1534.974.png/jcr:content

20.04.2016 19:51:58.953 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #130000 /content/dam/research/en/multimedia/2016/02/11/

 

20.04.2016 19:51:59.253 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #310000 /libs/wcm/core/content/editor/jcr:content/sidepanels/edit/items/componentsTab/items

20.04.2016 19:51:59.267 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #320000 /libs/granite/i18n/zh-cn/Done.

20.04.2016 19:51:59.281 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #330000 /var/audit/com.day.cq.dam/content/dam/research/en/multimedia/2016/01/12/a7059664-fc67-40cb-8a2c-88f31067797e/1.0

20.04.2016 19:51:59.297 *INFO* [http-bio-31010-exec-7] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Indexing report

 

Is this normal?

Avatar

Employee Advisor

Hi

restricting the uniqueness to a certain subtree of the repo isn't possible; I you really need this feature I would rather create a dedicated index on ths subtree with the uniqueness property, and a second one covering the remaining part of the repo without this property. And you should strongly consider to implement your index as Lucene index.

Jörg

Avatar

Level 5

Hey Jorg,

" I would rather create a dedicated index on ths subtree with the uniqueness property" - what would this involve? Creating the oak:QueryIndexDefinition node directly under the page tree i.e. /content/abc/reports rather than under oak:index?