Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nomilkinmyhome/elasticmapper
Easy generating ElasticSearch mappings based on ORM's models.
https://github.com/nomilkinmyhome/elasticmapper
codegen django elasticsearch mapping peewee sqlalchemy
Last synced: about 1 month ago
JSON representation
Easy generating ElasticSearch mappings based on ORM's models.
- Host: GitHub
- URL: https://github.com/nomilkinmyhome/elasticmapper
- Owner: nomilkinmyhome
- License: mit
- Created: 2022-07-16T14:36:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-10T12:27:53.000Z (over 1 year ago)
- Last Synced: 2024-07-14T14:03:58.180Z (about 2 months ago)
- Topics: codegen, django, elasticsearch, mapping, peewee, sqlalchemy
- Language: Python
- Homepage: https://elasticmapper.readthedocs.io/en/latest/index.html
- Size: 70.3 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- ru-awesome-opensource - Репозиторий проекта
README
# ElasticMapper
ElasticSearch mapper for three ORMs - SQLAlchemy, Peewee, DjangoORM.
Easy generating ElasticSearch mappings based on models.## Installation
```pip install elasticmapper```
## Basic usage
### Peewee example
```python
from peewee import *
from elasticmapper import PeeweeMapperdb = SqliteDatabase('my_app.db')
class BaseModel(Model):
class Meta:
database = dbclass User(BaseModel):
username = CharField(unique=True)
is_active = BooleanField(default=True)
age = IntegerField()user_elastic_mapping = PeeweeMapper(model=User).load()
```### SQLAlchemy example
```python
from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Integer, String, Boolean
from elasticmapper import SQLAlchemyMapperBase = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
username = Column(String)
is_active = Column(Boolean)
age = Column(Integer)user_elastic_mapping = SQLAlchemyMapper(model=User).load()
```### DjangoORM example
```python
from django.db import models
from elasticmapper import DjangoMapperclass User(models.Model):
username = models.CharField(max_length=30)
is_active = models.BooleanField(default=True)
age = models.IntegerField()user_elastic_mapping = DjangoMapper(model=User).load()
```#### Output for all examples:
```python
{
'id': {'type': 'integer'},
'username': {'type': 'text'},
'age': {'type': 'integer'},
'is_active': {'type': 'boolean'}
}
```## Documentation
Documentation lives [here](https://elasticmapper.readthedocs.io/en/latest/).
## Contributing
PR are welcome! If you want to help, please visit [the contribution guide](https://github.com/nomilkinmyhome/elasticmapper/blob/main/CONTRIBUTION_GUIDE.md), then take one of [the issues](https://github.com/nomilkinmyhome/elasticmapper/issues). Thank you for your contribution.
## License
Copyright © 2022 Polina Beskorovaynaya [ihatemilk](https://github.com/nomilkinmyhome)
This project has [MIT License](https://github.com/nomilkinmyhome/elasticmapper/blob/main/LICENSE).