|
|
|
(s/defn index-exists? :- s/Bool |
|
"check if the supplied ES index exists" |
|
[{:keys [uri request-fn] :as conn} :- ESConn |
|
index-name :- s/Str] |
|
(not= 404 |
|
(-> (make-http-opts conn {}) |
|
(assoc :method :head |
|
:url (index-uri uri index-name)) |
|
request-fn |
|
:status))) |
|
|
This function checks (not= 404 ...). For an example of why this is insufficient, authorization may fail (401), and thus this function will return true when in fact the specified index does not exist.
Steps to Reproduce
- Bring up the elasticsearch environment.
- Run the following in a REPL:
(require '[ductile.conn :as es.conn])
(require '[ductile.index :as es.index])
(def bad-auth-conn (es.conn/connect {:host "localhost"
:port 9207
:version 7
:protocol :http
:auth {:type :basic-auth
:params {:user "wrong"
:pwd "wrong"}}}))
(es.index/index-exists? bad-auth-conn "this_index_does_not_exist") ;; => true
Affects version: 0.4.4
ductile/src/ductile/index.clj
Lines 45 to 56 in e93d9a1
This function checks
(not= 404 ...). For an example of why this is insufficient, authorization may fail (401), and thus this function will return true when in fact the specified index does not exist.Steps to Reproduce
Affects version:
0.4.4