0

Previously using ElasticSearch Transport API, I have deleted an index and its data using the below line of program.

            DeleteByQueryAction.INSTANCE.newRequestBuilder(client).source(indexName).get();

We are migrated from Transport Client API to HTTP Client API now. Unfortunately this is not supported in ES HighLevel HTTP client API as for as I know. Is there a way to delete an index using HTTP client?

Edited: I am using ES Rest client API version 5.6.4. Deleting an index is available in the latest 6.x versions. I am looking for deleting the index in version 5.6.4. Thanks

2

1 Answer 1

2

Then I suggest simply making a DELETE call on your index using the low-level REST API, that'd do the trick

Response response = restClient.performRequest("DELETE", "/" + indexName); 

Note that you don't need to use the Delete by query API for deleting an index.

Sign up to request clarification or add additional context in comments.

4 Comments

It is working fine for deleting the particular index. But after deletion when I try to fetch data using that same index name I am getting some unexpected data instead of the message "that index not present" or something else. @Val do you have any idea what is wrong?
@Bran what message do you get?
Instead of any error or warning it returns some documents which did not come under that deleted index. NOTE : I have given only that index name(the deleted one) while searching.
I suggest you create a new question describing your exact problem, this thread is closed and it's not a good idea to cram another question in comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.