collectiveaccess / providence

Cataloguing and data/media management application
GNU General Public License v3.0
303 stars 170 forks source link

Deprecated geo_shape Parameter (precision) Causes Mapping Errors with Elasticsearch 8 #1649

Open jairomelo opened 1 week ago

jairomelo commented 1 week ago

I've recently encountered an issue while configuring Elasticsearch 8 with CollectiveAccess Providence (v1.8). During the search index rebuild process, the following error was raised:

PHP Fatal error: Uncaught Exception: Updating the ElasticSearch mapping failed. This is probably because of a type conflict. Try recreating the entire search index. The original error was {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Failed to parse mapping: using deprecated parameters [precision] in mapper [ca_objects/georeference] of type [geo_shape] is no longer allowed"}},"status":400}

The geo_shape field in the ElasticSearch.php plugin uses the precision parameter, which has been deprecated and is no longer supported in Elasticsearch 8. This causes the index creation to fail.

Affected Code: In the app/lib/Plugins/SearchEngine/ElasticSearch/Mapping.php file:

$va_element_config[$ps_table.'/'.$vs_element_code] = array(
    'type' => 'geo_shape',
    'precision' => '3m'
);

I modified the code to remove the deprecated precision parameter:

$va_element_config[$ps_table.'/'.$vs_element_code] = array(
    'type' => 'geo_shape'
);

It might be helpful for the development team to update this logic for compatibility with Elasticsearch 8. Perhaps conditional checks could be introduced for different Elasticsearch versions, or simply dropping the deprecated parameter as it is now internally handled by Elasticsearch.

Thanks for your great work!

collectiveaccess commented 1 week ago

We have not revised the ElasticSearch code for compatibility with recent versions. Thank you for these changes. We will look to integrate them in the coming months.