Created
January 24, 2024 00:50
-
-
Save julie-mills/49125b47699cd0b6c2b2a0c824e8e2c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from elasticsearch import Elasticsearch | |
# Connect to Elasticsearch | |
es = Elasticsearch([{'host': 'localhost', 'port': 9200}]) | |
# Index name and document ID | |
index_name = "your_index" | |
document_id = "1" | |
# Specify the fields to be updated | |
update_fields = { | |
"field1": "new_value1", | |
"field2": "new_value2" | |
} | |
# Use the update API to perform a partial update | |
es.update(index=index_name, id=document_id, body={"doc": update_fields}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment