Validate, compare, and synchronize Pydantic model schemas with Elasticsearch mappings.
Project description
📦 es-mapping-inspector
es-mapping-inspector is a Python utility to inspect and compare Elasticsearch mappings against Pydantic models. It helps ensure that your Elasticsearch index mapping is consistent with your application's data models.
✨ Features
- Compare Elasticsearch index mappings with Pydantic models.
- Inspect and retrieve detailed mapping information from an Elasticsearch index.
- Extract field definitions from Pydantic models for validation and debugging.
- Logging-friendly with no default logging configuration (uses
NullHandler).
📦 Installation
pip install es-mapping-inspector
🚀 Quick Start
from es_mapping_inspector import compare_es_mapping_with_model, EsMappingInspector, get_pydantic_model_fields
from my_models import MyPydanticModel
# 1. Inspect an Elasticsearch mapping
inspector = EsMappingInspector(es_client=my_es_client, index_name="my_index")
mapping = inspector.get_mapping()
# 2. Compare with a Pydantic model
differences = compare_es_mapping_with_model(
mapping=mapping,
model=MyPydanticModel
)
if differences:
print("Differences found:", differences)
# 3. Get Pydantic model fields
fields = get_pydantic_model_fields(MyPydanticModel)
print(fields)
📚 API Reference
compare_es_mapping_with_model(mapping, model) → dict
Compares an Elasticsearch mapping with a Pydantic model and returns any differences.
Parameters:
mapping(dict) – The Elasticsearch index mapping.model(BaseModel) – The Pydantic model to compare against.
class EsMappingInspector
Utility class to retrieve and analyze Elasticsearch mappings.
Methods:
get_mapping()– Retrieves the full index mapping from Elasticsearch.- (Additional methods as needed)
get_pydantic_model_fields(model) → dict
Returns a dictionary of field names and types from a Pydantic model.
🛠 Development
git clone https://github.com/yourusername/es-mapping-inspector.git
cd es-mapping-inspector
pip install -e ".[dev]"
Run tests:
pytest
📝 Versioning
This package follows Semantic Versioning.
Current version: __version__ from es_mapping_inspector.__about__.
📄 License
MIT License – see LICENSE file for details.
💡 Contributing
Pull requests are welcome! Please ensure code style and tests pass before submitting.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file es_mapping_inspector-0.1.2.tar.gz.
File metadata
- Download URL: es_mapping_inspector-0.1.2.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb073d71e93b9aba0627fb37feae22eec66f2cce7291c8bbd0ec78f57286b5cd
|
|
| MD5 |
3fbd3d973cb9d01efcd209f2e0bb8627
|
|
| BLAKE2b-256 |
f600da1eae3fdf7f5ca86a2ebe39cc5b49c04daf3fc547196861152276a92796
|
File details
Details for the file es_mapping_inspector-0.1.2-py3-none-any.whl.
File metadata
- Download URL: es_mapping_inspector-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6df0c9db8170836a4715677035ae3701966743d3dd67b5fcae3c411ee24e4221
|
|
| MD5 |
f30dbd459cd28dcd012600e3dd98138e
|
|
| BLAKE2b-256 |
ab91b1b46a90fb57dbd84d48a02255271909a950eb635b0e6d6a94410dbb510d
|