Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from elasticsearch import Elasticsearch
- import json
- try:
- es = Elasticsearch(['localhost','127.0.0.1'],port=9200,maxsize=25,)
- print "Connected", es.info()
- except Exception as ex:
- print "Error:", ex
- doc1 = {
- "script": {
- "inline": "ctx._source.ID++",
- "lang": "painless"
- },
- "query": {
- "term": {
- "username": "user100"
- }
- }
- }
- # HERE I TRIED MULTIPLE WAYS BUT NONE OF THEM WORKED.
- # res = es.update_by_query(index="jagan4", doc_type='1', body=doc1) # requies 4 args
- # res = es.update_by_query(index="jagan4", doc_type='1', id='1' body=doc1) # no ID match, but why need id to for function.
- res = es.update_by_query(index="jagan4", doc_type='1',q='username:"user100"', body=doc1)
- >Traceback (most recent call last):
- File "/home/jagan/Desktop/DevStack/workspace/jj.python.first/src/el-test.py", line 42, in <module>
- res = es.update_by_query(index="jagan4", doc_type='1',q='username:"user100"', body=doc1)
- **AttributeError: 'Elasticsearch' object has no attribute 'update_by_query**
- POST /jagan4/_update_by_query
- {
- "script": {
- "inline": "ctx._source.ID++",
- "lang": "painless"
- },
- "query": {
- "term": {
- "username": "user100"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement