EzDevInfo.com

elastisch

A minimalistic Clojure client for ElasticSearch, supports both HTTP and native transports Elastisch, a minimalistic Clojure client for ElasticSearch | ElasticSearch Clojure client

How to maintain two connections to different ElasticSearch hosts using Elastisch?

I’m using Elastisch, and the rest/connect function return an endpoint, but I can’t see how to reuse this endpoint when calling other functions. I need to transfer some documents from one index to another on different hosts, using a scroll on the first one and bulk indexing on the second one.


Source: (StackOverflow)

Clojure elastic search API Elastisch not returning results or documents

I am trying out clojure elastic search API Elastisch.

I was following the demo code given in the documentation I am getting document/index created output for the following code

(defn demo-search-connect []
  (esr/connect! "http://127.0.0.1:9200")
  (let [mapping-types {:person {:properties {:username   {:type "string" :store "yes"}
                                         :first-name {:type "string" :store "yes"}
                                         :last-name  {:type "string"}
                                         :age        {:type "integer"}
                                         :title      {:type "string" :analyzer
                                          "snowball"}
                                         :planet     {:type "string"}
                                         :biography  {:type "string" :analyzer   "snowball" :term_vector "with_positions_offsets"}}}}
    doc {:username "happyjoe" :first-name "Joe" :last-name "Smith" :age 30 :title "Teh Boss" :planet "Earth" :biography "N/A"}]

 (esi/create "myapp2_development" :mappings mapping-types)
;; adds a document to the index, id is automatically generated by ElasticSearch
;= {:ok true, :_index people, :_type person, :_id "2vr8sP-LTRWhSKOxyWOi_Q", :_version 1}
(println (esd/create "myapp2_development" :person doc :settings {"number_of_shards" 1}))
))

;Supposed to return an output for the search query 
(defn demo-search-index [] 
  (esr/connect! "http://127.0.0.1:9200")
  (esd/search "myapp2_development" "person" :query {:term {:last_name "Smith"}})
  )

;Supposed to return the document with the given id
(defn get-document [id]
  (esr/connect! "http://127.0.0.1:9200")
  (esd/get "myapp2_development" "person" id)
  )

I am getting the output for the first function as :

{:ok true, :_index myapp2_development, :_type :person, :_id GzNdzrqhQECQDlkSbq-GHA, :_version 1}

From the output I believe the document is getting indexed properly

The issue is that the second and third functions returns:

{:took 153, :timed_out false, :_shards {:total 5, :successful 5, :failed 0}, :hits {:total 0, :max_score nil, :hits []}}

and nil respectively.

What am I missing here?

P.S : I am new to clojure and elastic search


Source: (StackOverflow)

Advertisements