Chilkat Online Tools

VB6 / MongoDB Atlas / Delete an Atlas Search Index

Back to Collection Items

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

Dim http As New ChilkatHttp
Dim success As Long

http.DigestAuth = 1
http.Login = "username"
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"
'     ]
'   }
' ]

Dim jarr As New ChilkatJsonArray

success = jarr.AddObjectAt(-1)
Dim jsonObj_1 As ChilkatJsonObject
Set jsonObj_1 = jarr.ObjectAt(jarr.Size - 1)
success = jsonObj_1.UpdateString("name","my_new_analyzer")
success = jsonObj_1.UpdateString("baseAnalyzer","lucene.standard")
success = jsonObj_1.UpdateInt("maxTokenLength",48)

success = jarr.AddObjectAt(-1)
Set jsonObj_1 = jarr.ObjectAt(jarr.Size - 1)
success = jsonObj_1.UpdateString("name","my_other_new_analyzer")
success = jsonObj_1.UpdateString("baseAnalyzer","lucene.english")
success = jsonObj_1.UpdateString("stopwords[0]","foo")
success = jsonObj_1.UpdateString("stopwords[1]","bar")
success = jsonObj_1.UpdateString("stopwords[2]","baz")

Dim sbRequestBody As New ChilkatStringBuilder
success = jarr.EmitSb(sbRequestBody)

Dim resp As ChilkatHttpResponse
Set resp = http.PTextSb("DELETE","https://domain.com/api/atlas/{{version}}/groups/{{ProjectID}}/clusters/{{CLUSTER-NAME}}/fts/indexes/{{INDEX-ID}}",sbRequestBody,"utf-8","application/json",0,0)
If (http.LastMethodSuccess = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Debug.Print resp.StatusCode
Debug.Print resp.BodyStr

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": [
  ]
}