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.
@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"
]
}
}
},
Most helpful comment
@nrvakil Yes, the index types changed in elasticsearch 5.0. The
stringtype has been replaced by thetext(analyzed) andkeyword(not analyzed) types. You're specifying thetexttype, butkeywordis what you want for no analysis.