You can insert the data with below commands, example i have put 3 documents, but I have something around more than 1000 documents
test = [{'id':1,'name': 'A', 'subject': ['Maths', 'Accounting'],
'type':'Contract', 'Location':'NY'},
{ 'id':2, 'name': 'AB', 'subject': ['Physics', 'Engineering'],
'type':'Permanent','Location':'NY'},
{'id':3, 'name': 'ABC', 'subject': ['Maths', 'Engineering'],
'type':'Permanent','Location':'NY'}]
from elasticsearch import Elasticsearch
es = Elasticsearch()
for e in test:
es.index(index="myindex", body=e, id=e['id'])
- I need to delete documents from if
namematchesAB
I tried with below commands
names = ['AB']
for name in names:
es.delete_by_query(index="myindex", body={'name': name})
I got parsing exception, Unknown key for VALUE_STRING in [name]
While inserting into index i can ignore the name with
AB, but here I need to delete from the index if name matchesAB