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

Upsert documents with parent. #102

Closed
r0man opened this issue Jul 17, 2014 · 3 comments · Fixed by #103
Closed

Upsert documents with parent. #102

r0man opened this issue Jul 17, 2014 · 3 comments · Fixed by #103

Comments

@r0man
Copy link

r0man commented Jul 17, 2014

Hello,

I would like to upsert documents that have a parent. Right now
the upsert fn does not have any options to pass the parent. If
there's a interest I could send a PR for the upsert fn that
adds optional arguments in a similar way as the create fn. I
thought about something like this:

(defn upsert
  "Updates or creates a document using provided data"
  ([^Client conn index mapping-type ^String id ^Map doc & args]
     (let [{:keys [parent]} (ar/->opts args)
           req (cnv/->upsert-request index mapping-type id doc)
           req (if parent (.parent req parent) req)
           res (es/update conn req)]
       (cnv/update-response->map (.actionGet res)))))

Roman

@michaelklishin
Copy link
Member

@r0man can you link to the relevant ES documentation page? We can modify the existing API but I'd like to understand the feature better.

@r0man
Copy link
Author

r0man commented Jul 17, 2014

hey @michaelklishin,

When you create a document with Elastisch you can specify
the :parent of a document. This option is not available in the
upsert fn, which can also create a document. We used to do this
with HTTP PUT requests, but switching over to Elastisch now.

I think the docs you want is this one:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.html

In the Java API you can do this with the .parent method of the UpdateReqeust

https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/update/UpdateRequest.java#L176

Roman

@michaelklishin
Copy link
Member

@r0man please try master.

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

Successfully merging a pull request may close this issue.

2 participants