Re: [clojure-elasticsearch] Problems using bulk api

32 views
Skip to first unread message

Michael Klishin

unread,
Aug 5, 2015, 4:59:06 PM8/5/15
to Marcos Lamúria, clojure-el...@googlegroups.com
On 31 Jul 2015 at 13:23:03, Marcos Lamúria (marcos....@rupeal.com) wrote:
> I'm using elastisch, and I'm currently working on POC reading
> data from mysql database and indexing it on elasticsearch via
> bulk api. I've run into trouble.. I've got the following error:
>
> ERROR in (re-index-time-duration) (client.clj:183)
> Uncaught exception, not in assertion.
> expected: nil
> actual: clojure.lang.ExceptionInfo: clj-http: status 400
> data: {:orig-content-encoding nil,
> :trace-redirects ["http://127.0.0.1:9200/invoices/_bulk"],
> :request-time 110,
> :status 400,
> :headers
> {"Content-Length" "79",
> "Content-Type" "application/json; charset=UTF-8"},
> :body
> "{\"error\":\"ElasticsearchParseException[Failed to derive
> xcontent]\",\"status\":400}"}
> clj-http.client/wrap-exceptions/fn client.clj: 183
> clj-http.client/wrap-accept/fn client.clj: 535
> clj-http.client/wrap-accept-encoding/fn client.clj: 55
>
>
>
> And my code is:
>
> (defn fetch-all-data¬
> "Gets all needed data from storage"¬
> [account-id]¬
> {:account (first (j/query db ["select * from accounts where
> id = ?" account-id]))¬
> :clients (j/query db [" select * from clients where id = ?" account-id])})¬
> :documents (j/query db ["select * from invoices where account_id
> = ?" account-id])¬
> :products (j/query db ["select * from products where account_id
> = ?" account-id])})¬
>
> (defn write-in-elastic¬
> [data account]¬
> (let [conn elastic-conn¬
> documents (:documents data)]¬
> (blk/bulk-with-index conn "invoices" documents)))¬
>
> (defn run¬
> "Indexes account in elasticsearch"¬
> []¬
> (time¬
> (let [account-id #_5554 6599¬
> res (create-indexes)¬
> data (fetch-all-data account-id)]¬
> (write-in-elastic (:account data) data))))

I’m not sure what the documents value is. Status code 400
likely means ElasticSearch considers request body to be invalid,
specifically the  bulk action objects. 
--
@michaelklishin, github.com/michaelklishin
Reply all
Reply to author
Forward
0 new messages