
es:database-properties-generate( $model as map:map ) as object-node()
This function is deprecated and will not be supported in MarkLogic 11.
Generate a database configuration artifact from a basic model.
This data facilitates creating range indexes and lexicons required
for searching instance data.
| Parameters | |
|---|---|
| model | A valid basic entity model. |
This function produces JSON database configuration properties that you can use to configure a MarkLogic database. You can use the generated artifact as-is in an ml-gradle project, or customize it slightly for use with the REST Management API.
The configuration data includes a range index definition for each
entity type property specified in a es:range-index
element in the input model. Similarly, the configuration data
includes a word lexicon definition for each property specified in a
es:word-lexicon
element in the input model. These indexes and lexicon
definitions are compatible with the query options you can generate
using es:search-options-generate
function.
Your application might require additional database configuration. You can use the output of this function as a starting place from which to expand.
xquery version "1.0-ml";
import module namespace es = "http://marklogic.com/entity-services"
at "/MarkLogic/entity-services/entity-services.xqy";
es:database-properties-generate( es:model-validate(
<es:model xmlns:es="http://marklogic.com/entity-services">
<es:info>
<es:title>Example</es:title>
<es:version>1.0.0</es:version>
<es:description>ES Examples</es:description>
</es:info>
<es:definitions>
<Name>
<es:properties>
<first><es:datatype>string</es:datatype></first>
<middle><es:datatype>string</es:datatype></middle>
<last><es:datatype>string</es:datatype></last>
</es:properties>
<es:required>first</es:required>
<es:required>last</es:required>
</Name>
<Person>
<es:properties>
<id><es:datatype>int</es:datatype></id>
<name><es:ref>#/definitions/Name</es:ref></name>
<bio><es:datatype>string</es:datatype></bio>
<rating><es:datatype>float</es:datatype></rating>
<phone>
<es:datatype>array</es:datatype>
<es:items><es:datatype>string</es:datatype></es:items>
</phone>
<friend>
<es:datatype>array</es:datatype>
<es:items><es:ref>#/definitions/Person</es:ref></es:items>
</friend>
</es:properties>
<es:primary-key>id</es:primary-key>
<es:required>id</es:required>
<es:required>name</es:required>
<es:range-index>rating</es:range-index>
<es:word-lexicon>bio</es:word-lexicon>
</Person>
</es:definitions>
</es:model>
))
(: ==> A database configuration artifact similar to the following, as
: a JSON object node. You can use it as-is in an ml-gradle project,
: or set the values of the "database-name" and "schema-database"
: properties and use it with POST /manage/LATEST/databases to create
: a new database with this configuration.
{ "database-name": "%%DATABASE%%",
"schema-database": "%%SCHEMAS_DATABASE%%",
"path-namespace": [ {
"prefix": "es",
"namespace-uri": "http://marklogic.com/entity-services"
} ],
"element-word-lexicon": [ {
"collation": "http://marklogic.com/collation/en",
"localname": "bio",
"namespace-uri": ""
} ],
"range-path-index": [ {
"collation": "http://marklogic.com/collation/en",
"invalid-values": "reject",
"path-expression": "//es:instance/Person/rating",
"range-value-positions": false,
"scalar-type": "float"
} ],
"triple-index": true,
"collection-lexicon": true
}
:)
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.