Codoc-os / django-opensearch-dsl

This is a package that allows indexing of django models in opensearch with opensearch-py.
Other
24 stars 16 forks source link

Upserts & Partial updates #43

Open kwood opened 1 year ago

kwood commented 1 year ago

See docs at https://opensearch.org/docs/latest/api-reference/document-apis/update-document/

I need to add a test for upsert and docs for both — let me know if you're interested in merging this PR and I'm happy to add tests and docs.

codecov-commenter commented 1 year ago

Codecov Report

Merging #43 (b3a19fe) into master (830316e) will decrease coverage by 0.79%. The diff coverage is 70.58%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
- Coverage   95.65%   94.87%   -0.79%     
==========================================
  Files          12       12              
  Lines         576      585       +9     
  Branches       80       82       +2     
==========================================
+ Hits          551      555       +4     
- Misses         21       24       +3     
- Partials        4        6       +2     
Impacted Files Coverage Δ
django_opensearch_dsl/documents.py 93.75% <70.58%> (-4.31%) :arrow_down:
qcoumes commented 7 months ago

@kwood After a detailed look at the documentation, and as far as I understand, an upsert with doc_as_upsert: true is virtually identical to an index operation. If we want to support the upsert action, we should only do it with doc_as_upsert: false.

We could modify the _prepare_action to take optional doc_fields (would also be used for the partial update action) and upsert_fields, and used them with prepare's limit_fields to generate a valid body.