Partial update in native API and :doc key

8 views
Skip to first unread message

Henrik Lundahl

unread,
Nov 2, 2014, 1:56:23 PM11/2/14
to clojure-el...@googlegroups.com
Hi

I started working on a PR to get the partial update functionality into the native API. I noticed however that in the REST API you are supposed to include a :doc key, which I think is very unfortunate since you don't need to do that elsewhere. Wouldn't it be better if the :doc key was added by the API?

Which of these alternatives should I go for?

1. Implement the native API exactly as the REST API is now, but add a note about the :doc key in the function documentation in both APIs.
2. Change the REST API so it doesn't add the :doc key if the :doc key is the only key at root level and has a map as value.
3. Change the REST API so you can no longer use the :doc key. 2.1.0 is still beta, so maybe this is okay? The partial update function has been around since 2.1.0-beta1, though.
4. Other.


Kind regards,
Henrik

Michael Klishin

unread,
Nov 3, 2014, 4:24:48 AM11/3/14
to Henrik Lundahl, clojure-el...@googlegroups.com
On 2 November 2014 at 21:56:23, Henrik Lundahl (henrik....@gmail.com) wrote:
> 1. Implement the native API exactly as the REST API is now, but
> add a note about the :doc key in the function documentation in
> both APIs.
> 2. Change the REST API so it doesn't add the :doc key if the :doc
> key is the only key at root level and has a map as value.
> 3. Change the REST API so you can no longer use the :doc key. 2.1.0
> is still beta, so maybe this is okay? The partial update function
> has been around since 2.1.0-beta1, though.

3 is fine, however, I'm not sure how can partial update work without having
*some* keys and values to update with?

Partial update was never in a released version, so we can change it easily. 
--
@michaelklishin, github.com/michaelklishin

Henrik Lundahl

unread,
Nov 3, 2014, 7:08:55 AM11/3/14
to Michael Klishin, clojure-el...@googlegroups.com
You definitely need some keys to update with. I'm not quite sure why you're asking - I guess I was a bit unclear. Here is how it is today and how it will work after the changes:

* Before:
    * REST API:
        * doc argument: {:doc {:document-key-1 "Value 1"}}
        * The API code changes nothing before sending.
* After:
    * REST API:
        * doc argument: {:document-key-1 "Value 1"}
        * The API code wraps the doc argument in the :doc key before sending.
    * Native API:
        * doc argument: {:document-key-1 "Value 1"}

 Looks okay?

--
Henrik

Michael Klishin

unread,
Nov 3, 2014, 7:10:44 AM11/3/14
to Henrik Lundahl, clojure-el...@googlegroups.com
 On 3 November 2014 at 15:08:54, Henrik Lundahl (henrik....@gmail.com) wrote:
> * Before:
> * REST API:
> * doc argument: {:doc {:document-key-1 "Value 1"}}
> * The API code changes nothing before sending.
> * After:
> * REST API:
> * doc argument: {:document-key-1 "Value 1"}
>
> * The API code wraps the doc argument in the :doc key before sending.
> * Native API:
> * doc argument: {:document-key-1 "Value 1"}
>
> Looks okay?

Ah, so there's one extra layer of map nesting. Thank you for the explanation.

Yes, please go ahead and submit a PR. If we have any code examples for that in
the change log for earlier betas, we need to update them.

Thank you!
--
@michaelklishin, github.com/michaelklishin

Henrik Lundahl

unread,
Nov 3, 2014, 8:01:25 AM11/3/14
to Michael Klishin, clojure-el...@googlegroups.com
Yes, there is one here. Should I include changes to ChangeLog.md in the PR?

--
Henrik

Michael Klishin

unread,
Nov 3, 2014, 8:16:31 AM11/3/14
to Henrik Lundahl, clojure-el...@googlegroups.com
On 3 November 2014 at 16:01:25, Henrik Lundahl (henrik....@gmail.com) wrote:
> Yes, there is one here(https://github.com/clojurewerkz/elastisch/blob/master/ChangeLog.md#update-with-partial-document).
> Should I include changes to ChangeLog.md in the PR?

Yes, feel free to update change log as well .
--
@michaelklishin, github.com/michaelklishin
Reply all
Reply to author
Forward
0 new messages