Metadata-Version: 2.4
Name: es-mapping-inspector
Version: 0.1.2
Summary: Validate, compare, and synchronize Pydantic model schemas with Elasticsearch mappings.
Project-URL: Homepage, https://github.com/maximekieffer/es-mapping-inspector
Project-URL: Issues, https://github.com/maximekieffer/es-mapping-inspector/issues
Author: maximekieffer
License: MIT License
        
        Copyright (c) 2025 maximekieffer
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: elasticsearch,mapping,pydantic,schema,validation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Requires-Dist: elasticsearch<10,>=8
Requires-Dist: pydantic>=2.11.7
Requires-Dist: typer>=0.16.0
Description-Content-Type: text/markdown

# 📦 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

```bash
pip install es-mapping-inspector
```

---

## 🚀 Quick Start

```python
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

```bash
git clone https://github.com/yourusername/es-mapping-inspector.git
cd es-mapping-inspector
pip install -e ".[dev]"
```

Run tests:

```bash
pytest
```

---

## 📝 Versioning

This package follows [Semantic Versioning](https://semver.org/).
Current version: **`__version__`** from `es_mapping_inspector.__about__`.

---

## 📄 License

MIT License – see [LICENSE](LICENSE) file for details.

---

## 💡 Contributing

Pull requests are welcome! Please ensure code style and tests pass before submitting.
