VBScript / MongoDB Atlas / Delete an Atlas Search Index
Back to Collection Items
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' 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")
set http = CreateObject("Chilkat.Http")
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"
' ]
' }
' ]
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonArray")
set jarr = CreateObject("Chilkat.JsonArray")
success = jarr.AddObjectAt(-1)
' jsonObj_1 is a Chilkat.JsonObject
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)
' jsonObj_1 is a Chilkat.JsonObject
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")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbRequestBody = CreateObject("Chilkat.StringBuilder")
success = jarr.EmitSb(sbRequestBody)
' resp is a Chilkat.HttpResponse
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
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(resp.StatusCode)
outFile.WriteLine(resp.BodyStr)
outFile.Close
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": [
]
}