create(**kwargs) doesn't work if document id is not provided
See original GitHub issueElasticsearch version (bin/elasticsearch --version
): 7.6.2
elasticsearch-py
version (elasticsearch.__versionstr__
): 7.7.1
Please make sure the major version matches the Elasticsearch server you are running.
Description of the problem including expected versus actual behavior: Calling create(**kwargs) without providing a document Id causes an error when it should create a new document with autogenerated Id using POST method (instead of PUT).
Issue in init.py:
for param in (index, id, body): # id should be removed from here
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
if doc_type in SKIP_IN_PATH:
path = _make_path(index, "_create", id)
else:
path = _make_path(index, doc_type, id)
return self.transport.perform_request(
"POST" if id in SKIP_IN_PATH else "PUT", # calling "POST" instead of "PUT" is already implemented
path,
params=params,
headers=headers,
body=body,
)
Steps to reproduce:
Call create
method without providing a document Id and it will throw a ValueError
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Is is safe to use a function accepts kwargs keyword arguments ...
So, the documentation indicates that the mapping given to ** in a function call should only contain valid identifiers as keys, but CPython...
Read more >Supporting (or not) invalid identifiers in **kwargs - Ideas
I don't see why a string key that's not a valid identifier would open up an attack vector. Maybe you don't know how...
Read more >Make any callable compatible with (*args: Any, **kwargs: Any)?
Mypy lets you call such callable values with arbitrary arguments, without any checking – in this respect they are treated similar to a...
Read more >*args and **kwargs in Python - GeeksforGeeks
The special syntax *args in function definitions in python is used to pass a variable number of arguments to a function. It is...
Read more >API — Flask Documentation (2.2.x)
This part of the documentation covers all the interfaces of Flask. ... If the import name is not properly set up, that debugging...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@DuoPegla You’re able to create documents without specifying the
id
via.index()
:You can think of
create
as just for “create a document w/ ID without the option of updating it”..create()
requires an ID to verify that the document doesn’t already exist (will error in this case)..index()
when given an ID will either create the document or update it if it already exists. Basically.index()
is what you’re looking for here. 😃Thanks a lot! I must have missed that in the docs, just assumed given the name that
create
is the one I’m looking for.