Skip to content

Commit d4748c9

Browse files
committed
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.
1 parent b46f7e7 commit d4748c9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

example/load.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def load_repo(client, path=None, index='git'):
159159
{'_type': 'repos', '_id': 'elasticsearch', '_source': {
160160
'owner': {'name': 'Shay Bannon', 'email': 'kimchy@gmail.com'},
161161
'created_at': datetime(2010, 2, 8, 15, 22, 27),
162-
'tags': ['search', 'distributed', 'lucene', 'java'],
162+
'tags': ['search', 'distributed', 'lucene'],
163163
'description': 'You know, for search.'}
164164
},
165165

@@ -191,6 +191,21 @@ def load_repo(client, path=None, index='git'):
191191
es_repo = es.get(index='git', doc_type='repos', id='elasticsearch')
192192
print('%s: %s' % (es_repo['_id'], es_repo['_source']['description']))
193193

194+
# update - add java to es tags
195+
es.update(
196+
index='git',
197+
doc_type='repos',
198+
id='elasticsearch',
199+
body={
200+
"script": {
201+
"inline" : "ctx._source.tags.add(params.tag)",
202+
"params" : {
203+
"tag" : "java"
204+
}
205+
}
206+
}
207+
)
208+
194209
# refresh to make the documents available for search
195210
es.indices.refresh(index='git')
196211

0 commit comments

Comments
 (0)