Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
Make doc_type optional parameter
  • Loading branch information
lschanner-tenchi committed Jan 16, 2023
1 parent 054d669 commit 0768b99
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions opensearchpy/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,14 @@ def create(self, index, id, body, params=None, headers=None):
"version_type",
"wait_for_active_shards",
)
def index(self, index, body, id=None, params=None, headers=None):
def index(self, index, body, doc_type="_doc", id=None, params=None, headers=None):
"""
Creates or overwrites a document in an index.
:arg index: The name of the index
:arg body: The document
:arg doc_type: The document type
:arg id: Document ID
:arg if_primary_term: only perform the index operation if the
last operation that has changed the document has the specified primary
Expand Down Expand Up @@ -350,8 +351,6 @@ def index(self, index, body, id=None, params=None, headers=None):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")

doc_type = "_doc"

return self.transport.perform_request(
"POST" if id in SKIP_IN_PATH else "PUT",
_make_path(index, doc_type, id),
Expand Down

0 comments on commit 0768b99

Please sign in to comment.