Home > Software design >  Create element range index by MarkLogic REST API - Not creating element range in server , No error
Create element range index by MarkLogic REST API - Not creating element range in server , No error

Time:12-17

I am executing this CURL command to create element range index under Database : Schemas in MarkLogic.

Below is the CURL command :

CURL -X POST --digest -u admin:admin@123 -H "Content-type: application/json" \
-d '{
"range-element-indexes":[
    {"scalar-type":"dateTime", 
     "namespace-uri":"", 
     "localname":"test",      
     "collation":"", 
     "range-value-positions":"",
     "invalid-values":"reject", 
    }
 ]
}' \
http://127.0.0.1:8002/manage/v2/databases/Schemas/properties


I am getting no error , but I see no element range created in the server. 

CodePudding user response:

I see two issues:

  1. The /manage/v2/databases/{id|name}/properties supports GET and PUT verbs, not POST. So, you are going to want to change the POST to PUT.

  2. In the JSON payload the property range-element-indexes should be range-element-index (singular, not plural). It's a little confusing, but the differences between the XML format and the JSON format is that in XML there is a containing element called range-element-indexes that has a sequence of range-element-index children, but in JSON there is just a range-element-index property that has an array of objects. The documentation listing the properties is modeled from the XML and schema, not the JSON payloads.

After making those adjustments, I was able to PUT and create the range-index on my local instance.

  • Related