Skip to content

if_seq_no and if_primary_term in bulk action update #184

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

Closed
fy2 opened this issue Mar 30, 2020 · 7 comments
Closed

if_seq_no and if_primary_term in bulk action update #184

fy2 opened this issue Mar 30, 2020 · 7 comments
Assignees
Labels
Milestone

Comments

@fy2
Copy link

fy2 commented Mar 30, 2020

       $bulk->add_action(
           update => {
               id  => 123,
               doc => {
                   test_field   => "test test test",
               },
               if_seq_no       => $my_seq_no,
               if_primary_term => $my_primary_term
           },
       );

Is this the correct way to enter a bulk action for an update using the "if_seq_no" and "if_primary_term" parameters? I ask this because when I try it, I get an error:

Search::Elasticsearch::Error::Unknown params <if_primary_term,if_seq_no> in <update>"

Would you please let me know what the correct usage is?
ES version: 7.6
Search::Elasticsearch version: 6.80
Thanks.

@fy2
Copy link
Author

fy2 commented Apr 1, 2020

Hi @ezimuel , I have found that there is a bug in a library and that's causing the problem I have described above.

The fix is:

diff --git a/lib/Search/Elasticsearch/Client/6_0/Role/API.pm b/lib/Search/Elasticsearch/Client/6_0/Role/API.pm
index db54ae40..6c3ac70e 100644
--- a/lib/Search/Elasticsearch/Client/6_0/Role/API.pm
+++ b/lib/Search/Elasticsearch/Client/6_0/Role/API.pm
@@ -42,7 +42,9 @@ sub api {
             'version'       => 'version',
             '_version'      => 'version',
             'version_type'  => 'version_type',
-            '_version_type' => 'version_type'
+            '_version_type' => 'version_type',
+            'if_primary_term' => 'if_primary_term',
+            'if_seq_no'       => 'if_seq_no',
         }
     },
     'bulk.update' => {

I have not got time to create a proper PR yet (and run the unit tests), but if I find time in the coming weeks I will give it a go.

@ezimuel
Copy link
Contributor

ezimuel commented Apr 1, 2020

@fy2 Right now, elasticsearch-perl supports only Elasticsearch 6. We need to update all the APIs for Elasticsearch 7. I'm working now it and I'll release soon.

@fy2
Copy link
Author

fy2 commented Apr 1, 2020

@ezimuel , I think these options are also documented for ES 6 (see "if_seq_no and if_primary_term" section here: https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docs-update.html and in the bulk docs).

Thank you very much for your effort to upgrade!

@ezimuel
Copy link
Contributor

ezimuel commented Apr 1, 2020

@fy2 you right! This part of Client/6_0/Role/API.pl has not been updated with the ES 6.80 endpoints. I need to understand why this part is not managed by the script build/parse_spec_6_0.pl.
I'm working on it, thanks for reporting!

@ezimuel ezimuel self-assigned this Apr 1, 2020
@ezimuel ezimuel added the bug label Apr 1, 2020
@ezimuel ezimuel added this to the 6.81 milestone Apr 1, 2020
ezimuel added a commit to ezimuel/elasticsearch-perl that referenced this issue Jun 23, 2020
@ezimuel
Copy link
Contributor

ezimuel commented Jun 23, 2020

@fy2 I finally fixed this in #190, sorry for the delay.

@fy2
Copy link
Author

fy2 commented Jun 24, 2020

@fy2 I finally fixed this in #190, sorry for the delay.

Enrico, thanks a lot for the update.

Regards, Feyruz Yalcin

ezimuel added a commit that referenced this issue Jun 26, 2020
Fix for #184 adding if_seq_no and if_primary_term in bulk params
@ezimuel
Copy link
Contributor

ezimuel commented Jun 26, 2020

Just released 6.81 version that includes this fix. Updated also CPAN here: https://metacpan.org/release/EZIMUEL/Search-Elasticsearch-6.81

@ezimuel ezimuel closed this as completed Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants