File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
lib/elasticsearch/indexing
test/elasticsearch/indexing Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -58,12 +58,13 @@ defmodule Elasticsearch.Index do
58
58
| { :error , Elasticsearch.Exception . t ( ) }
59
59
def starting_with ( cluster , prefix ) do
60
60
with { :ok , indexes } <- Elasticsearch . get ( cluster , "/_cat/indices?format=json" ) do
61
- prefix = to_string ( prefix )
61
+ prefix = prefix |> to_string ( ) |> Regex . escape ( )
62
+ { :ok , regex } = Regex . compile ( "^#{ prefix } -[0-9]+$" )
62
63
63
64
indexes =
64
65
indexes
65
66
|> Enum . map ( & & 1 [ "index" ] )
66
- |> Enum . filter ( & String . starts_with? ( & 1 , prefix ) )
67
+ |> Enum . filter ( & Regex . match? ( regex , & 1 ) )
67
68
|> Enum . sort ( )
68
69
69
70
{ :ok , indexes }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ defmodule Elasticsearch.IndexTest do
16
16
{ :ok ,
17
17
% HTTPoison.Response {
18
18
status_code: 200 ,
19
- body: [ % { "index" => "index-name " } ]
19
+ body: [ % { "index" => "index-123 " } ]
20
20
} }
21
21
end
22
22
You can’t perform that action at this time.
0 commit comments