From c9f4ade0248869eca43ceb18dae991af8ee89fe1 Mon Sep 17 00:00:00 2001 From: Raffaele Vitiello Date: Wed, 7 Jan 2026 13:14:03 +0100 Subject: [PATCH] fix: add OpenSearch/Elasticsearch 7+ compatibility Remove deprecated type-based mappings and bulk endpoint format. - Remove type wrapper from mappings (was: {"mappings": {"_doc": {...}}}) Now uses flat structure: {"mappings": {...}} - Remove type from bulk endpoint (was: /{index}/_doc/_bulk) Now uses: /{index}/_bulk These changes maintain backward compatibility with Elasticsearch 7+ while adding support for OpenSearch. --- lib/searchyll/indexer.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/searchyll/indexer.rb b/lib/searchyll/indexer.rb index f967135..ca54047 100644 --- a/lib/searchyll/indexer.rb +++ b/lib/searchyll/indexer.rb @@ -130,8 +130,8 @@ def prepare_index } if configuration.elasticsearch_mapping - payload['mappings'] = {} - payload['mappings'].store(configuration.elasticsearch_default_type, configuration.elasticsearch_mapping) + # OpenSearch/ES 7+ doesn't support type in mappings - use flat structure + payload['mappings'] = configuration.elasticsearch_mapping end json_payload = payload.to_json @@ -177,7 +177,8 @@ def http_request(klass, path) # https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html def es_bulk_insert!(http, batch) return if batch.empty? - bulk_insert = http_post("/#{elasticsearch_index_name}/#{configuration.elasticsearch_default_type}/_bulk") + # OpenSearch/ES 7+ doesn't support type in bulk endpoint + bulk_insert = http_post("/#{elasticsearch_index_name}/_bulk") bulk_insert.content_type = 'application/x-ndjson' bulk_insert.body = batch.map do |doc| [{ index: {} }.to_json, doc.to_json].join("\n")