1
這是我的ActiveRecord定義Rails的:不能映射類型:完成(GEM:elasticsearch模型)
settings index: { number_of_shards: 1, number_of_replicas: 0 } do
mappings do
indexes :cas, type: 'string', index: "not_analyzed", analyzer: 'snowball'
indexes :names, type: 'string', analyzer: 'snowball'
indexes :names_cn, type: 'string', analyzer: 'ik_max_word'
indexes :suggest, type: 'completion', analyzer: 'snowball'
indexes :suggest_cn, type: 'completion', analyzer: 'ik_max_word'
end
end
def as_indexed_json(options = {})
{
cas: self.cas.to_s.strip,
names: self.suggests,
names_cn: self.suggests_cn,
suggest: { input: self.suggests },
suggest_cn: { input: self.chinese_keywords }
}
end
這是什麼elasticsearch服務器顯示我
{
"something-development": {
"aliases": {},
"mappings": {
"chemicals": {
"properties": {
"cas": {
"type": "string"
},
"names": {
"type": "string"
},
"names_cn": {
"type": "string"
},
"suggest": {
"properties": {
"input": {
"type": "string"
}
}
},
"suggest_cn": {
"properties": {
"input": {
"type": "string"
}
}
}
}
}
},
"settings": {
"index": {
"creation_date": "1470383173607",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "a8ONu0WSRGuImjLRU6ddVg",
"version": {
"created": "2030499"
}
}
},
"warmers": {}
}
}
我猜想建議& the suggest_cn項應該是這樣的:類型完成
suggest": {
"type": "completion",
"analyzer": "snowball",
"payloads": false,
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
}
也許我在理解這方面有一些問題。任何人都有幫助(最好的祝願)
https://github.com/elastic/elasticsearch-rails/issues/612我在這裏也有問題。