Noel Delgado
Noel Delgado

Reputation: 183

Searchkick/Elasticsearch - Root mapping definition has unsupported parameters

I have a Rails API on Heroku and get the following issue when reindexing a class.

$ heroku run rake searchkick:reindex CLASS=User

And get the following error

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [_default_ : {_routing={}, dynamic_templates=[{string_template={mapping={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}}}, match_mapping_type=string, match=*}}], properties={}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [_default_ : {_routing={}, dynamic_templates=[{string_template={mapping={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}}}, match_mapping_type=string, match=*}}], properties={}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [_default_ : {_routing={}, dynamic_templates=[{string_template={mapping={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}}}, match_mapping_type=string, match=*}}], properties={}}]"}},"status":400}

My User Class has the following

class User < ApplicationRecord
    searchkick settings: { 
        number_of_shards: 1,
        number_of_replicas: 1,
        max_ngram_diff: 49,
        max_shingle_diff: 4
        }
end

I am adding the max_ngram_diff and max_shingle_diff because that is solving a different issue. However, I am also not sure if I have the correct values for max_ngram_diff and max_shingle_diff.

From my Gemfile.lock

searchkick (2.5.0)
      activemodel (>= 4.1)
      elasticsearch (>= 1)
      hashie

elasticsearch (6.2.0)
      elasticsearch-api (= 6.2.0)
      elasticsearch-transport (= 6.2.0)
    elasticsearch-api (6.2.0)
      multi_json
    elasticsearch-transport (6.2.0)
      faraday
      multi_json

Any idea what to do, please?

Upvotes: 2

Views: 1393

Answers (1)

osazemeu
osazemeu

Reputation: 87

This error is due to version incompatibilities with ElasticSearch. I.e. The latest version of Searchkick ( i.e. v4.1), requires ElasticSearch v7.4.0

I encountered this error and solved it by downgrading my Elasticsearch from 7.x to 6.8.4. Was runninng SearchKick(3.1.2).

To check the version of ElasticSearch on your machine, run this command:

curl -XGET 'localhost:9200'

Check the version of searchkick running on your machine via Gemfile. From your gemfile, you need ElasticSearch v6.2.0 To install a specific version of ElasticSearch, run the following command

brew install [email protected]

Restart your elasticsearch service!

Upvotes: 1

Related Questions