Chilkat Online Tools

PowerBuilder / MongoDB Atlas / Delete an Atlas Search Index

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Jarr
oleobject loo_JsonObj_1
oleobject loo_SbRequestBody
oleobject loo_Resp

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.DigestAuth = 1
loo_Http.Login = "username"
loo_Http.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.

// [
//   {
//     "name": "my_new_analyzer",
//     "baseAnalyzer": "lucene.standard",
//     "maxTokenLength": 48
//   },
//   {
//     "name": "my_other_new_analyzer",
//     "baseAnalyzer": "lucene.english",
//     "stopwords": [
//       "foo",
//       "bar",
//       "baz"
//     ]
//   }
// ]

loo_Jarr = create oleobject
li_rc = loo_Jarr.ConnectToNewObject("Chilkat_9_5_0.JsonArray")

loo_Jarr.AddObjectAt(-1)
loo_JsonObj_1 = loo_Jarr.ObjectAt(loo_Jarr.Size - 1)
loo_JsonObj_1.UpdateString("name","my_new_analyzer")
loo_JsonObj_1.UpdateString("baseAnalyzer","lucene.standard")
loo_JsonObj_1.UpdateInt("maxTokenLength",48)
destroy loo_JsonObj_1

loo_Jarr.AddObjectAt(-1)
loo_JsonObj_1 = loo_Jarr.ObjectAt(loo_Jarr.Size - 1)
loo_JsonObj_1.UpdateString("name","my_other_new_analyzer")
loo_JsonObj_1.UpdateString("baseAnalyzer","lucene.english")
loo_JsonObj_1.UpdateString("stopwords[0]","foo")
loo_JsonObj_1.UpdateString("stopwords[1]","bar")
loo_JsonObj_1.UpdateString("stopwords[2]","baz")
destroy loo_JsonObj_1

loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Jarr.EmitSb(loo_SbRequestBody)

loo_Resp = loo_Http.PTextSb("DELETE","https://domain.com/api/atlas/{{version}}/groups/{{ProjectID}}/clusters/{{CLUSTER-NAME}}/fts/indexes/{{INDEX-ID}}",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Jarr
    destroy loo_SbRequestBody
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_Jarr
destroy loo_SbRequestBody

Curl Command

curl -X DELETE
	--digest -u 'username:password'
	-d '[
    {
        "name": "my_new_analyzer",
        "baseAnalyzer": "lucene.standard",
        "maxTokenLength": 48
    },
    {
        "name": "my_other_new_analyzer",
        "baseAnalyzer": "lucene.english",
        "stopwords": [
            "foo",
            "bar",
            "baz"
        ]
    }
]'
https://domain.com/api/atlas/{{version}}/groups/{{ProjectID}}/clusters/{{CLUSTER-NAME}}/fts/indexes/{{INDEX-ID}}

Postman Collection Item JSON

{
  "name": "Delete an Atlas Search Index",
  "request": {
    "method": "DELETE",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "[\n    {\n        \"name\": \"my_new_analyzer\",\n        \"baseAnalyzer\": \"lucene.standard\",\n        \"maxTokenLength\": 48\n    },\n    {\n        \"name\": \"my_other_new_analyzer\",\n        \"baseAnalyzer\": \"lucene.english\",\n        \"stopwords\": [\n            \"foo\",\n            \"bar\",\n            \"baz\"\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-delete-one/"
  },
  "response": [
  ]
}