ruby - Setting up Facets in Elasticsearch with Searchkick gem in Rails 4.1 -
I would like users to easily find a series so that they want to set aspects. I have followed the instructions and everything is working fine, but when I print the setup, I get a refund in the following form. I want them to have such documents in their documents. Hope someone can help you.
I get it in myapp.com/movies
{"name" => {"_type" = & gt; "Terms", "missing" => 0, "total" = & gt; 1, "Other" = & gt; 0, "Rule" = & gt; [{"Word" = & gt; "Bloop", "Count" = & gt; 1}]}, "IMDB" = & gt; {"_type" = & gt; "Terms", "missing" => 0, "total" = & gt; 1, "Other" = & gt; 0, "Rule" = & gt; [{"Word" = & gt; "Http://www.bloop.com", "Calculation" = & gt; 1}]}}
# app / view / movies / index.html.erb <% = p @ series.facets%>
# app / controller / movies_controller RB DIF Index Query = Parameters [: Query]. Pisces || "*" @movie = movie. Search: (query, page: parameters [: page], suggestion: correct, per page: 20, aspect: [: 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 "update_at" end
Finally I found this after doing this work. Not sure that this is the best way, but it works! Hope this helps, and if you have improvements or suggestions, feel free to tell me.
# app / model / movie Rb def self.facets_search (params) query = params [: query] presence || "*" Terms = {conditions} [: year] = Param [: year] If the consultation [: year]. Display? Movies = Movie Search queries, where: status, aspect: [: year], smart_fats: true, page: params [: page], suggestion: right, highlights: true, per page: 10 movies end
.
# app / controller / movies_controllerRbD Def Index = Movies = Movie. Fits_search (Parameters) and
.
# apps / views / movies / index.html.erb <% if @ movies.facets ["year"] ["conditions"]. is present? & Gt%; & Lt; Div & gt; & Lt; Ul & gt; & Lt;% @ movies.facets ["year"] ["rule"]. Do each. Filter | & Gt%; & Lt; Li & gt; & Lt;% = link_to "# {Filter {" word "]} (# {filter [" count "]}" ", / movies? Year = # {filter [" word "]}"%>; <% end%>
Comments
Post a Comment