Restore fixed update example in example/load.py
Earlier I'd misread the Scripting and Security page about inline scripts - turns out they are enabled by default. Earlier failures I saw were due to old groovy syntax. Things are working after changing to painless.
This commit is contained in:
+16
-1
@@ -159,7 +159,7 @@ REPO_ACTIONS = [
|
|||||||
{'_type': 'repos', '_id': 'elasticsearch', '_source': {
|
{'_type': 'repos', '_id': 'elasticsearch', '_source': {
|
||||||
'owner': {'name': 'Shay Bannon', 'email': '[email protected]'},
|
'owner': {'name': 'Shay Bannon', 'email': '[email protected]'},
|
||||||
'created_at': datetime(2010, 2, 8, 15, 22, 27),
|
'created_at': datetime(2010, 2, 8, 15, 22, 27),
|
||||||
'tags': ['search', 'distributed', 'lucene', 'java'],
|
'tags': ['search', 'distributed', 'lucene'],
|
||||||
'description': 'You know, for search.'}
|
'description': 'You know, for search.'}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -191,6 +191,21 @@ if __name__ == '__main__':
|
|||||||
es_repo = es.get(index='git', doc_type='repos', id='elasticsearch')
|
es_repo = es.get(index='git', doc_type='repos', id='elasticsearch')
|
||||||
print('%s: %s' % (es_repo['_id'], es_repo['_source']['description']))
|
print('%s: %s' % (es_repo['_id'], es_repo['_source']['description']))
|
||||||
|
|
||||||
|
# update - add java to es tags
|
||||||
|
es.update(
|
||||||
|
index='git',
|
||||||
|
doc_type='repos',
|
||||||
|
id='elasticsearch',
|
||||||
|
body={
|
||||||
|
"script": {
|
||||||
|
"inline" : "ctx._source.tags.add(params.tag)",
|
||||||
|
"params" : {
|
||||||
|
"tag" : "java"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
# refresh to make the documents available for search
|
# refresh to make the documents available for search
|
||||||
es.indices.refresh(index='git')
|
es.indices.refresh(index='git')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user