3

I have create a Field in marklogic through Admin console and I want to configure the same setting through ml-gradle to avoid manually creation from Admin console. Is there any way to configure through ml-gradle?

mpuram
  • 149
  • 9

1 Answers1

3

I was looking for an example in the ml-gradle project, but couldn't find one.

There is an easy way to discover how to provide it though. There is documentation for the Management REST api that already provides a lot of detail, but an example usually works better. Now that you created a field with Admin ui manually, you can discover the JSON syntax for it easily using the Management REST api, and copy/paste that into your ml-gradle database config.

You can use the database properties REST call to discover this:

https://docs.marklogic.com/REST/GET/manage/v2/databases/[id-or-name]/properties

This basically comes down to something like:

http://localhost:8002/manage/v2/databases/my-database/properties?format=json

You can also just navigate to http://localhost:8002/manage/v2/ with your browser, and navigate the HTML pages to your database. Find the properties, and add a format=json request parameter to the url to get them printed as JSON. You can use a JS or JSON formatter to pretty-print it for easier reading.

In case you are speaking of a regular field with paths, here is an example:

  "field": [
    {
      "field-name": "dateTime",
      "field-path": [
        {
          "path": "dateTime",
          "weight": 1
        },
        {
          "path": "dateTimes",
          "weight": 1
        }
      ]
    }
  ]

The range index that can optionally go with this, is defined separately.

HTH!

grtjn
  • 20,254
  • 1
  • 24
  • 35