es.databasePropertiesGenerate( model as Object ) as objectNode()
This function is deprecated and will be removed in a future release.
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 rangeIndex
property in the input model. Similarly, the configuration data
includes a word lexicon definition for each property specified in a
wordLexicon
property in the input model. These indexes and lexicon
definitions are compatible with the query options you can generate
using
es.searchOptionsGenerate
function.
Your application might require additional database configuration. You can use the output of this function as a starting place from which to expand.
const es = require('/MarkLogic/entity-services/entity-services'); es.databasePropertiesGenerate( es.modelValidate( { "info": { "title": "Example", "description": "ES Examples", "version": "1.0.0", }, "definitions": { "Name" : { "properties": { "first": { "datatype": "string" }, "middle": { "datatype": "string" }, "last": { "datatype": "string" } }, "required": ["first", "last"] }, "Person": { "properties": { "id": { "datatype": "int" }, "name": { "$ref": "#/definitions/Name", }, "bio": { "datatype": "string" }, "rating": { "datatype": "float" }, "phone": { "datatype": "array", "items": { "datatype": "string"} }, "friend": { "datatype" : "array", "items": { "$ref" : "#/definitions/Person" } } }, "required": ["id", "name"], "primaryKey" : "id", "rangeIndex": ["rating"], "wordLexicon": ["bio"] } }} )); /* 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 } */