]> git.joonet.de Git - adminer.git/commit
Elastic: Fix record insertion on Elasticsearch 7
authorChristian Weiske <cweiske@cweiske.de>
Mon, 10 Mar 2025 07:42:49 +0000 (08:42 +0100)
committerJakub Vrána <jakub@vrana.cz>
Mon, 10 Mar 2025 20:13:16 +0000 (21:13 +0100)
commite9934624123cb78b3648175d69478e53b80e4380
tree3a377b159cc17eb673595f67aef9f3480b62cfa4
parent31f8f61d0e59d6cd79489455218c44b8de170814
Elastic: Fix record insertion on Elasticsearch 7

1. Make values NULLable by default, so that empty values do not
get submitted to the Elasticsearch server.
This helps e.g. with empty date fields - Elasticsearch would try to
convert the field type to string when the value is an empty string,
but that fails when there are documents with properly filled date fields

2. Remove _id from the POST array because this is not allowed.
The server fails if it is included with
> mapper_parsing_exception:
> Field [_id] is a metadata field and cannot be added inside a document.
> Use the index API request parameters.

3. Use the correct URL to create a document: "$index/_doc/"
and "$index/_doc/$id". This is the same for ES 7 and 8:
- https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html#docs-index-api-request
- https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-index_.html#docs-index-api-request

4. Handle failed creations by checking for false

5. Return the "result" property string instead of the non-existing
"created" property.
plugins/drivers/elastic.php