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
5858 | { :error , Elasticsearch.Exception . t ( ) }
5959 def starting_with ( cluster , prefix ) do
6060 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]+$" )
6263
6364 indexes =
6465 indexes
6566 |> Enum . map ( & & 1 [ "index" ] )
66- |> Enum . filter ( & String . starts_with? ( & 1 , prefix ) )
67+ |> Enum . filter ( & Regex . match? ( regex , & 1 ) )
6768 |> Enum . sort ( )
6869
6970 { :ok , indexes }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ defmodule Elasticsearch.IndexTest do
1616 { :ok ,
1717 % HTTPoison.Response {
1818 status_code: 200 ,
19- body: [ % { "index" => "index-name " } ]
19+ body: [ % { "index" => "index-123 " } ]
2020 } }
2121 end
2222
You can’t perform that action at this time.
0 commit comments