es-mapping-inspector


Namees-mapping-inspector JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryValidate, compare, and synchronize Pydantic model schemas with Elasticsearch mappings.
upload_time2025-08-18 08:50:32
maintainerNone
docs_urlNone
authormaximekieffer
requires_python>=3.9
licenseMIT 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.
keywords elasticsearch mapping pydantic schema validation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 📦 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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "es-mapping-inspector",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "elasticsearch, mapping, pydantic, schema, validation",
    "author": "maximekieffer",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ca/06/bfe43193a6bdba85029bbb559b1d34359ddf322923f887d80420ecd9ace0/es_mapping_inspector-0.1.1.tar.gz",
    "platform": null,
    "description": "# \ud83d\udce6 es-mapping-inspector\n\n**es-mapping-inspector** is a Python utility to inspect and compare Elasticsearch mappings against Pydantic models.\nIt helps ensure that your Elasticsearch index mapping is consistent with your application's data models.\n\n---\n\n## \u2728 Features\n\n* **Compare** Elasticsearch index mappings with Pydantic models.\n* **Inspect** and retrieve detailed mapping information from an Elasticsearch index.\n* **Extract** field definitions from Pydantic models for validation and debugging.\n* **Logging-friendly** with no default logging configuration (uses `NullHandler`).\n\n---\n\n## \ud83d\udce6 Installation\n\n```bash\npip install es-mapping-inspector\n```\n\n---\n\n## \ud83d\ude80 Quick Start\n\n```python\nfrom es_mapping_inspector import compare_es_mapping_with_model, EsMappingInspector, get_pydantic_model_fields\nfrom my_models import MyPydanticModel\n\n# 1. Inspect an Elasticsearch mapping\ninspector = EsMappingInspector(es_client=my_es_client, index_name=\"my_index\")\nmapping = inspector.get_mapping()\n\n# 2. Compare with a Pydantic model\ndifferences = compare_es_mapping_with_model(\n    mapping=mapping,\n    model=MyPydanticModel\n)\nif differences:\n    print(\"Differences found:\", differences)\n\n# 3. Get Pydantic model fields\nfields = get_pydantic_model_fields(MyPydanticModel)\nprint(fields)\n```\n\n---\n\n## \ud83d\udcda API Reference\n\n### `compare_es_mapping_with_model(mapping, model) \u2192 dict`\n\nCompares an Elasticsearch mapping with a Pydantic model and returns any differences.\n\n**Parameters:**\n\n* `mapping` *(dict)* \u2013 The Elasticsearch index mapping.\n* `model` *(BaseModel)* \u2013 The Pydantic model to compare against.\n\n---\n\n### `class EsMappingInspector`\n\nUtility class to retrieve and analyze Elasticsearch mappings.\n\n**Methods:**\n\n* `get_mapping()` \u2013 Retrieves the full index mapping from Elasticsearch.\n* *(Additional methods as needed)*\n\n---\n\n### `get_pydantic_model_fields(model) \u2192 dict`\n\nReturns a dictionary of field names and types from a Pydantic model.\n\n---\n\n## \ud83d\udee0 Development\n\n```bash\ngit clone https://github.com/yourusername/es-mapping-inspector.git\ncd es-mapping-inspector\npip install -e \".[dev]\"\n```\n\nRun tests:\n\n```bash\npytest\n```\n\n---\n\n## \ud83d\udcdd Versioning\n\nThis package follows [Semantic Versioning](https://semver.org/).\nCurrent version: **`__version__`** from `es_mapping_inspector.__about__`.\n\n---\n\n## \ud83d\udcc4 License\n\nMIT License \u2013 see [LICENSE](LICENSE) file for details.\n\n---\n\n## \ud83d\udca1 Contributing\n\nPull requests are welcome! Please ensure code style and tests pass before submitting.\n",
    "bugtrack_url": null,
    "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.",
    "summary": "Validate, compare, and synchronize Pydantic model schemas with Elasticsearch mappings.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/maximekieffer/es-mapping-inspector",
        "Issues": "https://github.com/maximekieffer/es-mapping-inspector/issues"
    },
    "split_keywords": [
        "elasticsearch",
        " mapping",
        " pydantic",
        " schema",
        " validation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "27281cff5b78024ee98124b16c05d6119b10e5a4a011ada2d2b8db926b9c2bdb",
                "md5": "0fb3ac2dad5988c1d7615bbbd6915725",
                "sha256": "ef163f0dc065269ee89e1c3aacdd1dee16a485d8dcfb32937bd26bb78db85224"
            },
            "downloads": -1,
            "filename": "es_mapping_inspector-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0fb3ac2dad5988c1d7615bbbd6915725",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9342,
            "upload_time": "2025-08-18T08:50:31",
            "upload_time_iso_8601": "2025-08-18T08:50:31.876099Z",
            "url": "https://files.pythonhosted.org/packages/27/28/1cff5b78024ee98124b16c05d6119b10e5a4a011ada2d2b8db926b9c2bdb/es_mapping_inspector-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ca06bfe43193a6bdba85029bbb559b1d34359ddf322923f887d80420ecd9ace0",
                "md5": "0e5f5f3fc689b4ac92d03e7ae6c461a8",
                "sha256": "f4f2384df59bb329ea1db7c887d0a07b06578a465630542b6e163043a14e3550"
            },
            "downloads": -1,
            "filename": "es_mapping_inspector-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0e5f5f3fc689b4ac92d03e7ae6c461a8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9544,
            "upload_time": "2025-08-18T08:50:32",
            "upload_time_iso_8601": "2025-08-18T08:50:32.715430Z",
            "url": "https://files.pythonhosted.org/packages/ca/06/bfe43193a6bdba85029bbb559b1d34359ddf322923f887d80420ecd9ace0/es_mapping_inspector-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-18 08:50:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maximekieffer",
    "github_project": "es-mapping-inspector",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "es-mapping-inspector"
}
        
Elapsed time: 0.56588s