ref: master
plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
require_relative '../helpers/elasticsearch_helper' require_relative '../helpers/elasticsearch_plugin_helper' class ElasticsearchPluginController < ApplicationController no_design_blocks include ElasticsearchHelper helper ElasticsearchPluginHelper def index search end def search define_searchable_types define_sort_types define_categories define_results respond_to do |format| format.html { render :action => 'search' } format.js params["format"] = "" end end def define_results @query = params[:query] @current_page = params[:page] @results = process_results @hits = (@results.try(:total) || 0) end def define_searchable_types @searchable_types = searchable_types @selected_type = (params[:selected_type] || :all).to_sym end def define_sort_types @sort_types = sort_types @selected_sort = (params[:filter] || :relevance).to_sym end def define_categories @categories = Category.where(parent: nil) @selected_categories = (params[:categories] || "").split(",") end end |