Foxpro / MongoDB Atlas / Update an Atlas Search Index
Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
loHttp.DigestAuth = 1
loHttp.Login = "username"
loHttp.Password = "password"
* Use this online tool to generate code from sample JSON: Generate Code to Create JSON
* The following JSON is sent in the request body.
* {
* "collectionName": "synonyms",
* "database": "my_test",
* "name": "default",
* "mappings": {
* "dynamic": true
* },
* "analyzer": "lucene.standard",
* "synonyms": [
* {
* "name": "egSynonyms",
* "source": {
* "collection": "synonyms"
* },
* "analyzer": "lucene.standard"
* }
* ]
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("collectionName","synonyms")
loJson.UpdateString("database","my_test")
loJson.UpdateString("name","default")
loJson.UpdateBool("mappings.dynamic",1)
loJson.UpdateString("analyzer","lucene.standard")
loJson.UpdateString("synonyms[0].name","egSynonyms")
loJson.UpdateString("synonyms[0].source.collection","synonyms")
loJson.UpdateString("synonyms[0].analyzer","lucene.standard")
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbRequestBody = CreateObject('Chilkat.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loResp = loHttp.PTextSb("PATCH","https://domain.com/api/atlas/{{version}}/groups/{{ProjectID}}/clusters/{{CLUSTER-NAME}}/fts/indexes/{{INDEX-ID}}",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
CANCEL
ENDIF
? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
Curl Command
curl -X PATCH
--digest -u 'username:password'
-d '{
"collectionName": "synonyms",
"database": "my_test",
"name": "default",
"mappings": {
"dynamic": true
},
"analyzer": "lucene.standard",
"synonyms": [
{
"name": "egSynonyms",
"source": {
"collection": "synonyms"
},
"analyzer": "lucene.standard"
}
]
}'
https://domain.com/api/atlas/{{version}}/groups/{{ProjectID}}/clusters/{{CLUSTER-NAME}}/fts/indexes/{{INDEX-ID}}
Postman Collection Item JSON
{
"name": "Update an Atlas Search Index",
"request": {
"method": "PATCH",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"collectionName\": \"synonyms\",\n \"database\": \"my_test\",\n \"name\": \"default\",\n \"mappings\": {\n \"dynamic\": true\n },\n \"analyzer\": \"lucene.standard\",\n \"synonyms\": [\n {\n \"name\": \"egSynonyms\",\n \"source\": {\n \"collection\": \"synonyms\"\n },\n \"analyzer\": \"lucene.standard\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{base_url}}/api/atlas/{{version}}/groups/{{ProjectID}}/clusters/{{CLUSTER-NAME}}/fts/indexes/{{INDEX-ID}}",
"host": [
"{{base_url}}"
],
"path": [
"api",
"atlas",
"{{version}}",
"groups",
"{{ProjectID}}",
"clusters",
"{{CLUSTER-NAME}}",
"fts",
"indexes",
"{{INDEX-ID}}"
]
},
"description": "https://docs.atlas.mongodb.com/reference/api/fts-indexes-create-one/"
},
"response": [
]
}