elasticsearch
elasticsearch 내 Wildcard expressions or all indices are not allowed 에러 해결
42 views
Elasticsearch에서 테스트로 만든 인덱스를 전부 지우고 싶을 때가 있습니다. 이때 DELETE 명령어와 와일드카드(*)를 사용하면 매우 편리한데요,
예를 들어 DELETE test.*라고 입력하여 test로 시작하는 모든 인덱스를 한 번에 삭제할 수 있습니다.
그런데, DELETE test.* 명령어를 실행했을 때, 다음과 같은 400 에러가 발생할 수 있습니다
text
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Wildcard expressions or all indices are not allowed"
}
],
"type": "illegal_argument_exception",
"reason": "Wildcard expressions or all indices are not allowed"
},
"status": 400
}
이 에러는 Elasticsearch 클러스터의 설정 때문에 발생한다. 기본적으로 와일드카드를 사용한 DELETE 명령은 허용되지 않습니다.
설정을 변경하면 되는데, 아래에 방법을 작성 합니다.
해결 방법: 클러스터 설정 변경하기
아래 API 호출하여, 클러스터의 설정을 변경한다.
text
PUT /_cluster/settings
{
"transient": {
"action.destructive_requires_name": true
}
}
설정을 변경한 후에 DELETE test.* 명령어를 사용하여 test로 시작하는 모든 인덱스를 정상적으로 삭제할 수 있다.
결론
설정을 변경하면 * 형태로 전체 Index 삭제가 가능하다.
