Skip to content

Instantly share code, notes, and snippets.

@Poogles
Created June 8, 2017 15:16
Show Gist options
  • Save Poogles/8811de2040994391ae897f7386253200 to your computer and use it in GitHub Desktop.
Save Poogles/8811de2040994391ae897f7386253200 to your computer and use it in GitHub Desktop.
Spandex Bulk Index
(ns foo.index
(:require [qbits.spandex :as spandex])
(:gen-class))
;; You'll have to fix the types, away from my computer so I just wrote something in so you're sure what they do.
(defn generate-index-request
"Take an esindex path and a message and generate a index map."
^Map [^String esindex ^Map message ^String type]
(let [type (keyword type)
kwindex (keyword esindex)]
[{:index {:_index kwindex :_type type :_id nil}} ;; Nil ID is required for ES to genereate an ID.
message]))
;; Push the result of this onto the bulk channel they offer and it should work.
;; Shout if that's not enough.
@faxm0dem
Copy link

faxm0dem commented Jun 8, 2017

thanks, I was playing around with the sync API and realized I had to run the edn through spandex/chunks->body first (which the bulk channel does for you)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment