【发布时间】:2015-01-09 02:30:04
【问题描述】:
我有一个Article 模型:
class Article < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
settings default_options do
mapping do
indexes :id, index: :not_analyzed
indexes :roles do
indexes :machine_name, analyzer: 'keyword'
end
indexes :published_at, type: 'date', include_in_all: false
end
end
end
default_options 在哪里:
index: { store: { type: Rails.env.test? ? :memory : :niofs },
analysis: {
analyzer: {
default: {
tokenizer: "standard",
filter: ["asciifolding", "lowercase", "snowball"],
char_filter: ["html_strip"]
}
}
}
我只是想在过滤角色的同时搜索文章,但我不知道该怎么做。我一直在尝试这样的事情但没有成功:
Tire.search("article") do
query { string 'foo bar baz' }
filter :nested, { path:'roles',
query: {
filtered: {
query: {
match_all: {}
},
filter: {
term:{'roles.machine_name' => ['da']}
}
}
}
}
end
这给了我这个错误:
QueryParsingException[[development-oaciq::application-article] [nested] nested object under path [roles] is not of nested type];
【问题讨论】:
标签: ruby-on-rails elasticsearch tire