简体   繁体   中英

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

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. 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM