0

I'm trying to work through the [Elastisch tutorial] to create some test data in an ElasticSearch instance running on a VM.

I am running this code:

(ns content-rendering.core
  (:require [clojurewerkz.elastisch.native       :as esr]
            [clojurewerkz.elastisch.native.index :as esi]))

(defn populate-test-data
  []
  (let [conn (esr/connect "http://10.10.10.101:9200")]
    (esi/create conn "test")))

(populate-test-data)

And I am seeing the following exception when I try and execute the code in the namespace using either Cider in emacs or from a Leiningen repl:

Caused by java.lang.UnsupportedOperationException
   nth not supported on this type: Character

                   RT.java:  933  clojure.lang.RT/nthFrom
                   RT.java:  883  clojure.lang.RT/nth
                native.clj:  266  clojurewerkz.elastisch.native/connect
                  core.clj:    7  content-rendering.core/populate-test-data
                  core.clj:   10  content-rendering.core/eval5078

If I require the Elastisch namespaces into a repl and run something like the following, it works fine:

(def conn (esr/connect "http://10.10.10.101:9200"))
(esi/create conn "test")  ; {:acknowledged true}

Any ideas what I'm missing here?

Chris Mc
  • 25
  • 3

1 Answers1

1

There are two clients in elastisch, the REST one and the native one. You're using the native transport, but passing it the REST URL when it expects a seq of [host port] pairs.

You can switch to the REST client by changing esr/esi to their clojurewerkz.elastisch.rest pendants, or point the native one to the correct endpoints:

(esr/connect [["10.10.10.101" 9300]])

If your cluster name is not the default you have to set it using an additional options map:

(esr/connect [["10.10.10.101" 9300]] {"cluster.name" "my-es"})
xsc
  • 5,983
  • 23
  • 30