Sto usando client python Elasticsearch come http://elasticsearch-py.readthedocs.org/ Ho provato a fondo ma non sono riuscito a trovare l'aggiornamento api con upsert. Qualcuno potrebbe darmi un esempio con ES python client upsert api per favore.come usare python Elasticsearch client upsert api
9
A
risposta
16
Il codice di esempio come segue:
from elasticsearch import Elasticsearch
es = Elasticsearch("localhost:9200")
es.update(index='test',doc_type='test1',id='1',body={'doc':{'username':'Tom'},'doc_as_upsert':True})
se non c'è doc_as_upsert=true
sarebbe buttare eccezione quando l'id non è in vigore. Inoltre, assicurati che i tuoi dati siano stati inseriti nel documento {}.
1
Il metodo index(*args, **kwargs)
aggiunge o aggiorna un documento JSON digitato in un indice specifico, rendendolo ricercabile.
Come indicato in Python Elasticsearch Client -> API Documentation.
> Inoltre, assicurati che i tuoi dati siano stati inseriti nel documento {}. Grazie –
@LelouchLamperouge è obbligatorio usare 'doc'? – anekix