我希望用户能够轻松找到一个系列,因此想要设置方面。我已按照seachkick的指示进行操作,一切正常,但是当我设置 Facets 时,我得到以下回报。我希望它像他们的文档中一样。希望有人可以提供帮助。
我在 myapp.com/movies 得到这个
{
"name"=> {
"_type"=> "terms",
"missing"=> 0,
"total"=> 1,
"other"=> 0,
"terms"=> [
{
"term"=> "Bloop",
"count"=> 1
}
]
},
"imdb"=> {
"_type"=> "terms",
"missing"=> 0,
"total"=> 1,
"other"=> 0,
"terms"=> [
{
"term" => "http://www.bloop.com",
"count" => 1
}
]
}
}
#app/views/movies/index.html.erb
<%= p @series.facets %>
#app/controllers/movies_controller.rb
def index
query = params[:query].presence || "*"
@movies = Movie.search(query, page: params[:page],
suggest: true,
per_page: 20,
facets: [:name, :imdb])
end
#db/schema.rb
create_table "movies", force: true do |t|
t.string "name"
t.text "description"
t.string "imdb"
t.string "year"
t.datetime "created_at"
t.datetime "updated_at"
end