Hi Thomas,

On Tue, Jan 31, 2017 at 5:07 PM,  <thom...@apache.org> wrote:
> +The following script created the index externalId:
> +
> +    // create-externalId.txt
> +    // create a unique index on externalId
> +    {"print": "check if externalId already exists"}
> +    {"xpath": "/jcr:root/oak:index/externalId"}
> +    {"if": "$resultSize", "=": 1, "print": "index externalId already exists"}
> +    {"$create": []}
> +    {"if": "$resultSize", "=": 0, "$create": [1]}
> +    {"for": "$create", "do": [
> +        {"print": "does not exist; creating..."},
> +        {"addNode": "/oak:index/externalId", "node": {
> +            "jcr:primaryType": "oak:QueryIndexDefinition",
> +            "{Name}propertyNames": ["rep:externalId"],
> +            "type": "property",
> +            "unique": true
> +        }},
> +        {"session": "save"},
> +        {"print": "done; index is now:"},
> +        {"xpath": "/jcr:root/oak:index/externalId", "depth": 2}
> +    ]}
> +    exit

Scripting in JSON looks interesting!

However would like to understand the approach here and how it should
be used. Oak Console already uses Groovy and can execute those script
via ":load" construct. We already use this with customer setups to
execute scripts hosted on github [1], [2] So not sure why we need to
use this approach and how it meets the requirement for OAK-5324


Chetan Mehrotra
[1] https://gist.github.com/stillalex/e7067bcb86c89bef66c8
[2] https://gist.github.com/chetanmeh/d7588d96a839dd2d26760913e4055215

Reply via email to