Exception in thread "main" clojure.lang.ExceptionInfo: clj-http: status 405
{:status 405,
:headers {"Allow" "GET,PUT,HEAD,DELETE", "content-type" "application/json; charset=UTF-8", "content-length" "146"},
:body "{\"error\":\
"Incorrect HTTP method for uri [/slack_lens_20160820] and method [POST], allowed: [GET, PUT, HEAD, DELETE]\",\"status\":405}",
:request-time 244, :trace-redirects ["http://127.0.0.1:9200/slack_lens_20160820"],
:orig-content-encoding "gzip"}, compiling:(/tmp/form-init1822303649317959720.clj:1:73)
at clojure.lang.Compiler.load(Compiler.java:7239)
at clojure.lang.Compiler.loadFile(Compiler.java:7165)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invoke(main.clj:308)
at clojure.main$null_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
The index is not created yet, the code that might have caused it.
(esi/create conn index-name :settings settings :mappings mappings)
And in elasticsearch:1.7 it was working fine but with the newer version 6.0 clj-http it fails.
In Elasticsearch 6.0+, the client needs to send a
PUT /myindex
request to explicitly create an index, rather than just aPOST /myindex
. It appears that the ES client that you are using needs to be updated.You can see from the body of the response:
The
POST
is not allowed, you need to use a different verb. You can confirm it works by doing: