I can't find how should I proceed to disable _source field when using the Python elasticsearch-dsl API.
Thanks
I can't find how should I proceed to disable _source field when using the Python elasticsearch-dsl API.
Thanks
I answer my self:
You can dynamically create a DocType class to support the elasticsearch-dsl methods, like this.
With dicc
being a dictionary with the types, like:
es = Elasticsearch()
dicc = {'date': Date(), 'age': Integer(), 'location': GeoPoint(), 'ip': Ip(), 'name': Keyword(), 'comments': Text()}
if args.no_source: #to disable _source field
dicc[doc_type] = {'_source' : {'enabled' : False}}
if args.no_all: #to disable _all field
dicc[doc_type] = {'_all' : {'enabled' : False}}
DocClass = type(doc_type, (DocType,), dicc)
DocClass.init(index='indexname', using=es)
And it works !
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.