[
]
Elastic Search Mapping Generator
what 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 well
documentation :
- UML Diagram
Constructor:
* number_of_shards: default shards is 1
* number_of_replicas: default is 0
add_feilds(feild_name=None,type=None,index=True,keywords=True):
- This is main method which does most of work for you
type:
- Type can be text for full text search see link for more details https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html
index : Default value is True
- The 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.html
keywords : Default value is True
- Read more https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html
- if you dont want keywords set this to False
Installation
pip install elasticsearchmappinggenerator
Usage
Schema
{
"first_name":"Soumil ",
"last_name":"Shah"
}
from elasticsearchmappinggenerator.elasticsearchmappinggenerator import ElasticMappingGenerator
import json
def main():
_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"
}
}
def main():
_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 better
Authors
Soumil Nitin Shah
- Excellent 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.com
- Github: https://github.com/soumilshah1995
- Linkedin: https://www.linkedin.com/in/shah-soumil/
- Blog: https://soumilshah1995.blogspot.com/
- Youtube : https://www.youtube.com/channel/UC_eOodxvwS_H7x2uLQa-svw?view_as=subscriber
- Facebook Page : https://www.facebook.com/soumilshah1995/
- Email : shahsoumil519@gmail.com
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Metadata
Release files for elasticsearchmappinggenerator 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| elasticsearchmappinggenerator-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for elasticsearchmappinggenerator-2.0.0-py3-none-any.whl |
Release files / elasticsearchmappinggenerator-2.0.0-py3-none-any.whl
| Download URL | elasticsearchmappinggenerator-2.0.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28052574b19e970fe3498f2d7031cf2fe3b54c39450552ed8086420fc34f5e72
|
|
BLAKE2b-256 checksum How to use checksums |
1abc107cb16c01cac023b768e8294e965f4c17d00a20f1181181830b92c27117
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
|
Security for elasticsearchmappinggenerator 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.