I want the users to be able to easily find a series so want to set up facets. I have followed the directions at seachkick and everything is working fine, but when I setup Facets, I am getting the following as the return. I want it to be like in their documentation. Hope someone can help.
I get this in 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
I finally got it working by doing the following. Not sure if it is the best method but it works! Hope it helps and if you have improvements or suggestions feel free to let me know.
.
.