Set elasticsearch options dynamically #19
Answered
by
wallneradam
poppelaars
asked this question in
Q&A
-
Hi, When using the esproxy I am able to call functions from the elasticsearch library. from esorm import es
user = await es.options(
headers={
"es-security-runas-user": username,
},
basic_auth=(settings.elasticsearch_username, settings.elasticsearch_password)
).security.authenticate() Is it possible "out-of-the-box" to set elasticsearch options dynamically, such as a header, dynamically when using an esorm model? For example inside: from esorm import ESModel
# Here the model have automatically generated id
class User(ESModel):
name: str
age: int
async def create_user():
# Create a new user
user = User(name='John Doe', age=25)
# Save the user to ElasticSearch
new_user_id = await user.save()
print(new_user_id) |
Beta Was this translation helpful? Give feedback.
Answered by
wallneradam
Aug 6, 2024
Replies: 1 comment
-
I've never used this feature of ES. So you would like to have different headers for the communications of a specific model? If you check the source code, there is a |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wallneradam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've never used this feature of ES. So you would like to have different headers for the communications of a specific model?
If you check the source code, there is a
call
method of theESModel
. You could easily override it. Then every ES call will use your headers.