Reputation: 177
I'm interested in creating field index using script. Seen a function which creates field index with include root. Didn't find a function which can create the field with path index.
Tried this function
admin:database-add-field-paths($config, $dbid, $field-name, $field-path)
Show "No field exist" in error.
Any suggestion on this.
Upvotes: 0
Views: 95
Reputation: 20414
I think you are looking for admin:database-path-field
. It's output can be added to the admin config using admin:database-add-field
, roughly like follows:
let $config := admin:get-configuration()
let $dbid := xdmp:database()
let $fieldspec :=
let $field-name := "myField"
let $field-paths := admin:database-field-path("/a/b", xs:double(2.0))
return
admin:database-path-field($field-name, $field-paths)
let $newConfig := admin:database-add-field($config, $dbid, $fieldspec)
It might also be worth taking a look at the Management REST api, which allows deploying configuration from outside, and with less programming. You'd need to send a PUT request to :8002/manage/v2/databases/[id-or-name]/properties
, with something like the following as part of the payload:
"field": [
{
"field-name": "status",
"field-path": [
{
"path": "/pdbe:person-envelope/pdbm:person/pdbm:status",
"weight": 1
},
{
"path": "/pdbm:person/pdbm:status",
"weight": 1
}
],
"field-value-searches": true
}
]
HTH!
Upvotes: 1