Elasticsearch-rails: Failed to parse value [not_analyzed] as only [true] or [false] are allowed.

Created on 14 Dec 2017  路  3Comments  路  Source: elastic/elasticsearch-rails

I get the following error:

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Failed to parse mapping [note]: Could not convert [raw.index] to boolean"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [note]: Could not convert [raw.index] to boolean","caused_by":{"type":"illegal_argument_exception","reason":"Could not convert [raw.index] to boolean","caused_by":{"type":"illegal_argument_exception","reason":"Failed to parse value [not_analyzed] as only [true] or [false] are allowed."}}},"status":400}

Model: (ploymorphic)

class Note < ApplicationRecord
  include Elasticsearch::Model
  include Elasticsearch::Model::Callbacks

  mappings dynamic: 'false' do
      indexes :noteable_type, type: 'text', index: :not_analyzed
  end

  # ...
end

Note.__elasticsearch__.create_index! force: true

Am am I doing something wrong? Or some syntax has changed again? Please help. Thanks.

Most helpful comment

@nrvakil Yes, the index types changed in elasticsearch 5.0. The string type has been replaced by the text (analyzed) and keyword (not analyzed) types. You're specifying the text type, but keyword is what you want for no analysis.

  mappings dynamic: 'false' do
    indexes :noteable_type, type: 'keyword'
  end

All 3 comments

@nrvakil Yes, the index types changed in elasticsearch 5.0. The string type has been replaced by the text (analyzed) and keyword (not analyzed) types. You're specifying the text type, but keyword is what you want for no analysis.

  mappings dynamic: 'false' do
    indexes :noteable_type, type: 'keyword'
  end

That did it. Thanks @nilbus .

I changed this "preserve_original": 1 to "preserve_original": "True" and worked

            "analysis": {
                "filter": {
                    "email": {
                        "type": "pattern_capture",
                        "preserve_original": True,
                        "patterns": [
                            "([^@]+)",
                            "(\\p{L}+)",
                            "(\\d+)",
                            "@(.+)",
                            "([^-@]+)"
                        ]
                    }
                },
                "analyzer": {
                    "email": {
                        "tokenizer": "uax_url_email",
                        "filter": [
                            "email",
                            "lowercase",
                            "unique"
                        ]
                    }
                }
            },
Was this page helpful?
0 / 5 - 0 ratings