对Elasticsearch和Rails感到头痛。
我有两个模型,我想做父/子关系和查询
模型古兰经:: Ayah
class Quran::Ayah < ActiveRecord::Base
extend Quran
has_many :translations, class_name: 'Content::Translation', foreign_key: 'ayah_key'
mapping do
indexes :ayah_index, type: 'integer'
indexes :surah_id, type: 'integer'
indexes :ayah_num, type: 'integer'
indexes :page_num, type: 'integer'
indexes :juz_num, type: 'integer'
indexes :hizb_num, type: 'integer'
indexes :rub_num, type: 'integer'
indexes :text, type: 'string'
indexes :ayah_key, type: 'string'
indexes :translations, type: :nested do
indexes :text
indexes :ayah_key
end
end
end
模型内容::翻译
class Content::Translation < ActiveRecord::Base
extend Content
extend Batchelor
self.table_name = 'translation'
self.primary_keys = :ayah_key, :resource_id
belongs_to :resource, class_name: 'Content::Resource'
belongs_to :ayah, class_name: 'Quran::Ayah'
mapping :_parent => { :type => 'ayah' } do
indexes :resource_id, type: "integer"
indexes :ayah_key
indexes :text
end
end
每次我导入时,都会给我这个错误:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":"RoutingMissingException[routing is required for [content-translations]/[translation]/[1]]","status":400}