diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5d01fc7..08c2aeb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,7 @@ Changelog - Add heartbeat (fixes #3) - Delete indices when buckets and collections are deleted (fixes #21) - Support quick search from querystring (fixes #34) +- Support defining mapping from the ``index:schema`` property in the collection metadata (ref #8) **Bug fixes** diff --git a/README.rst b/README.rst index c3909f9..591ac98 100644 --- a/README.rst +++ b/README.rst @@ -126,6 +126,38 @@ Or an advanced search using request body: } +Custom index mapping +-------------------- + +By default, ElasticSearch infers the data types from the indexed records. + +But it's possible to define the index mappings (ie. schema) from the collection metadata, +in the ``index:schema`` property: + +.. code-block:: bash + + $ echo '{ + "data": { + "index:schema": { + "properties": { + "id": {"type": "keyword"}, + "last_modified": {"type": "long"}, + "build": { + "properties": { + "date": {"type": "date", "format": "strict_date"}, + "id": {"type": "keyword"} + } + } + } + } + } + }' | http PATCH "http://localhost:8888/v1/buckets/blog/collections/builds" --auth token:admin-token --verbose + +Refer to ElasticSearch official documentation for more information about mappings. + +See also, `domapping `_ a CLI tool to convert JSON schemas to ElasticSearch mappings. + + Running the tests =================