My goal is to quickly clear the index, but I found that the 'delete-by_query' courier is slow, so I plan to delete it first and then create a new index like before, but I find that errors often occur:
Welcome!
Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.
Instead, paste the text and format it with </>
icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.
It would be great if you could update your post to solve this.
This message indicates that the index lj_test1
already exists.
You need to describe a bit more what calls you are doing.
Normally, running:
DELETE lj_test1
PUT lj_test1
should not cause that.
Which version are you using?
Sorry, this is my first time using this community and I am not yet proficient.
Elasticsearch Version
7.17.21
Installed Plugins
No response
Java Version
21.0.2
OS Version
3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Problem Description
My goal is to quickly clear the index, but I found that the 'delete-by_query' courier is slow, so I plan to delete it first and then create a new index like before, but I find that errors often occur:
Steps to Reproduce
- create index
PUT / lj_test1 {
"settings": {
"number_of_shards": 10,
"number_of_replicas": 6
},
"mappings": {
"properties": {
"name1": {
"type": "text"
},
"name2": {
"type": "text"
},
"name3": {
"type": "text"
},
"name4": {
"type": "text"
},
"name5": {
"type": "text"
},
"name6": {
"type": "text"
}
}
}
}
- Delete index
DELETE /lj_test1
- After completing step 2, quickly re execute step 1
note: If not reproduced, please increase the number of shards and replicas slightly
Logs
{
"error" : {
"root_cause" : [
{
"type" : "resource_already_exists_exception",
"reason" : "index [lj_test1/wWP6JOWvSL2mRePTHQ4YDQ] already exists",
"index_uuid" : "wWP6JOWvSL2mRePTHQ4YDQ",
"index" : "lj_test1"
}
],
"type" : "resource_already_exists_exception",
"reason" : "index [lj_test1/wWP6JOWvSL2mRePTHQ4YDQ] already exists",
"index_uuid" : "wWP6JOWvSL2mRePTHQ4YDQ",
"index" : "lj_test1"
},
"status" : 400
}
I described it in the ES issue before, please refer to this (Recreate index, error 'resource_already_exists_exception' · Issue #111945 · elastic/elasticsearch · GitHub) for details
What is the specification of your cluster? How many nodes? How much CPU, RAM and heap do you have assigned? What type of storage are you using?
If you can not resolve this a possible workaround would be to create an alias that sits in front of the index. Having this allows you to clear the index using the following steps:
- At the start the alias A points to the existing index A1, which holds the data you want to clear.
- Create a new, empty backing index A2 with the correct mapping.
- In a single operation remove the alias A from A1 and add it to index A2.
- Remove the A1 index.
As I mentioned in the issue, I think the problem is that you are not waiting for a successful response from the delete step. I cannot reproduce this. Please share the output from all three API calls, rather than just the last one.