Package: elasticsearchmappinggenerator
[]Elastic Search Mapping Generatorwhat is Elastic Search Mapping Generator  ?For the past few months,Â i have been working on elastic search. I notice that it's hard to generate dynamic Query for elastic search it would be great if we had a class that can generate these complex queries. that's the reason I published an open-source library on PyPI that can generate these queries for youÂLink :https://pypi.org/project/elasticsearchquerygenerator/Similar approach i wanted to create something that can generate elastic search mapping as welldocumentation :UML DiagramConstructor:* number_of_shards: default shards is 1 
* number_of_replicas: default is 0add_feilds(feild_name=None,type=None,index=True,keywords=True):This is main method which does most of work for youtype:Type can be text for full text search see link for more detailshttps://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.htmlindex : Default value is  TrueThe index option controls whether field values are indexed. It accepts true or false and defaults to true. Fields that are not indexed are not queryable.https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.htmlkeywords : Default value is  TrueRead morehttps://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.htmlif you dont want keywords set this to FalseInstallationpipinstallelasticsearchmappinggeneratorUsageSchema{"first_name":"Soumil  ","last_name":"Shah"}fromelasticsearchmappinggenerator.elasticsearchmappinggeneratorimportElasticMappingGeneratorimportjsondefmain():_helper=ElasticMappingGenerator(number_of_replicas=1,number_of_shards=20)_helper.add_feilds(feild_name='first_name',type='text',index=True,keywords=False)_helper.add_feilds(feild_name='last_name',type='text',index=True)query=_helper.complete_mappings()print(json.dumps(query,indent=3))if__name__=='__main__':main()Output :{"settings":{"index":{"number_of_shards":20,"number_of_replicas":1}},"mappings":{"properties":{"name":{"properties":{"first_name":{"type":"text","index":true},"last_name":{"type":"text","index":true,"fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}}}Generating Nested Schema{"name":{"first_name":"Soumil  ","last_name":"Shah"}}defmain():_helper=ElasticMappingGenerator(number_of_replicas=1,number_of_shards=20)_helper.add_feilds(feild_name='name.first_name',type='text',index=True,keywords=False)_helper.add_feilds(feild_name='name.last_name',type='text',index=True)query=_helper.complete_mappings()print(json.dumps(query,indent=3))if__name__=='__main__':main()output{"settings":{"index":{"number_of_shards":20,"number_of_replicas":1}},"mappings":{"properties":{"name":{"properties":{"first_name":{"type":"text","index":true},"last_name":{"type":"text","index":true,"fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}}}i would be adding more examples and making it better and betterAuthorsSoumil Nitin ShahExcellent experience of building scalable and high-performance Software Applications combining distinctive skill sets in Internet of Things (IoT), Machine Learning and Full Stack Web Development in Python.Bachelor in Electronic Engineering |
Masters in Electrical Engineering |
Master in Computer Engineering |Website :https://soumilshah.herokuapp.comGithub:https://github.com/soumilshah1995Linkedin:https://www.linkedin.com/in/shah-soumil/Blog:https://soumilshah1995.blogspot.com/Youtube :https://www.youtube.com/channel/UC_eOodxvwS_H7x2uLQa-svw?view_as=subscriberFacebook Page :https://www.facebook.com/soumilshah1995/Email :shahsoumil519@gmail.comLicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for details