Skip to content

Instantly share code, notes, and snippets.

@julie-mills
Created January 24, 2024 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julie-mills/49125b47699cd0b6c2b2a0c824e8e2c0 to your computer and use it in GitHub Desktop.
Save julie-mills/49125b47699cd0b6c2b2a0c824e8e2c0 to your computer and use it in GitHub Desktop.
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