Elasticsearch-rails ( https://github.com/elasticsearch/elasticsearch-rails )を介して Rails 4 で ElasticSearch を使用しています。
メール属性を持つ User モデルがあります。
ドキュメントに記載されている「uax_url_email」トークナイザーを使用しようとしています。
class User < ActiveRecord::Base
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
settings analysis: { analyzer: { whole_email: { tokenizer: 'uax_url_email' } } } do
mappings dynamic: 'false' do
indexes :email, analyzer: 'whole_email'
end
end
end
wiki ( https://github.com/elasticsearch/elasticsearch-rails/wiki ) と elasticsearch-model ドキュメント ( https://github.com/elasticsearch/elasticsearch-rails/wiki ) の例に従って、これにたどり着きました.
うまくいきません。直接elasticsearchにクエリを実行すると:
curl -XGET 'localhost:9200/users/_mapping
戻り値:
{
"users": {
"mappings": {
"user": {
"properties": {
"birthdate": {
"type": "date",
"format": "dateOptionalTime"
},
"created_at": {
"type": "date",
"format": "dateOptionalTime"
},
"email": {
"type": "string"
},
"first_name": {
"type": "string"
},
"gender": {
"type": "string"
},
"id": {
"type": "long"
},
"last_name": {
"type": "string"
},
"name": {
"type": "string"
},
"role": {
"type": "string"
},
"updated_at": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
}