singla_02
(Abhishek Singla)
March 7, 2019, 6:09pm
1
want to delete time based indices on Elasticsearch older than some specific (let's say 30) days using date math expression in JAVA.
Trying to implement following approach in our spring boot application using Transaport Client but getting index not exist exception.
Date math support in system and index alias names | Elasticsearch Guide [8.11] | Elastic
When the same URI encoded index name (which is passed to DELETE INDEX API) is used to search index using query GET uri_encoded_index_name on kibana, It shows that index exists.
Is there something I am missing out ?
Is there any better approach to do that without using curator and wilcard characters?
code snippet:
String indexName = "<" + indexNameStaticPart + "{now/d-30d{MMddYYYY}}>";
String encodedIndexName = UriEncoder.encode( indexName ).replace( "/", "%2F" );
AcknowledgedResponse response = client.admin().indices().delete( new DeleteIndexRequest( encodedIndexName ) ).actionGet();
encodedIndexName = %3Cstring__string_string__%7Bnow%2Fd-30d%7BMMddyyyy%7D%7D%3E
kibana:
GET encodedIndexName
DELETE encodedIndexName
ylasri
(Yassine LASRI)
March 9, 2019, 8:56am
2
singla_02
(Abhishek Singla)
March 9, 2019, 10:46am
3
Yeah, I know but I was just wondering why this is not working.
dadoonet
(David Pilato)
March 9, 2019, 11:16am
4
What do you have in encodedIndexName
? Could you print its value?
singla_02
(Abhishek Singla)
March 9, 2019, 1:37pm
5
%3Cstring__string_string__%7Bnow%2Fd-30d%7BMMddyyyy%7D%7D%3E
dadoonet
(David Pilato)
March 9, 2019, 1:56pm
6
It does not look like an index name unless indexNameStaticPart
is really string__string_string
.
What gives
GET /_cat/indices?v
Do you have an index named string__string_string__02072019
?
singla_02
(Abhishek Singla)
March 9, 2019, 2:39pm
7
Yes
GET /_cat/indices?v
shows list of all the indices, among them one is string__string_string__02072019
even
GET %3Cstring__string_string__%7Bnow%2Fd-30d%7BMMddyyyy%7D%7D%3E
shows the index mappings and settings
dadoonet
(David Pilato)
March 9, 2019, 6:24pm
8
Did you try without doing the url encoding?
1 Like
singla_02
(Abhishek Singla)
March 9, 2019, 7:10pm
9
Yeah I just. It worked out. Thanks man.
Any idea why is it different from the provided documentation ?
singla_02
(Abhishek Singla)
March 9, 2019, 8:02pm
11
1 Like
dadoonet
(David Pilato)
March 9, 2019, 8:41pm
12
I see. I believe that the high level client does encoding if needed.
system
(system)
Closed
April 6, 2019, 8:42pm
13
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.