Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native.document.[create, put] should support versioning #56

Closed
richievos opened this issue Jan 10, 2014 · 2 comments
Closed

native.document.[create, put] should support versioning #56

richievos opened this issue Jan 10, 2014 · 2 comments

Comments

@richievos
Copy link
Contributor

Related to #54 another issue we're running into is elastisch doesn't seem to support using the optimistic locking built into elasticsearch. Specifically, on the index-request, one should be able to trigger a setVersion call.

Docs on setVersion: https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java#L281

This should probably just be another when in https://github.com/clojurewerkz/elastisch/blob/master/src/clojurewerkz/elastisch/native/conversion.clj#L148

(when version
  (.version version)    
@richievos
Copy link
Contributor Author

Workaround for put

;; Put workaround
; Acts like native.document.put, but supports :version. Replace calls to this with es-doc/put when
; https://github.com/clojurewerkz/elastisch/issues/56 is fixed
(defn- put [index-name type document & { :as options }]
  (let [index-request (cnv/->index-request index-name type document options)]
    (if-let [version (:version options)]
      (.version index-request version))

    ; Note: this should really be .actionGet not .get (https://github.com/clojurewerkz/elastisch/issues/54)
    (cnv/index-response->map (.get (es-native/index index-request)))))

@michaelklishin
Copy link
Member

@richievos feel free to submit a pull request. This feature is likely newer than Elastisch's native client.

richievos added a commit to richievos/elastisch that referenced this issue Jan 11, 2014
@richievos richievos reopened this Jan 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants