Class: SearchController

Inherits:
ApplicationController show all
Includes:
ControllerUtils, MultiDataset
Defined in:
app/controllers/search_controller.rb

Instance Method Summary collapse

Methods included from MultiDataset

#create_all_models, #create_model, #dataspecs_by_name, #get_all_facets, #get_all_field_info, #get_all_searchable_fields, #get_all_truncated_fields, #get_dataspec, #get_model, #loadAllDatasets, #load_everything, #run_all, #use_all_or_some

Methods included from GeneralUtils

#genLink, #getHR, #get_date_index, #get_search_param, #paramMatch?

Methods included from MiscProcess

#gen_class_name, #make_facet_version, #process_pic, #set_name

Methods included from ControllerUtils

#get_total_docs, #page_calc

Methods included from FacetsQuery

#build_facet_filters, #get_all_categories

Methods included from DataspecUtils

#checkIfX, #getFieldDetails, #sortFields

Instance Method Details

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/search_controller.rb', line 6

def index
  # Calculate start and page num
  pagenum, start = page_calc(params)
  
  # Pass params to SearchQuery model (which builds query and gets results)
  params.delete_if { |k, v| v.empty? }
  s = SearchQuery.new(params, start)
  query, model_to_search = s.build_query
  
  # Searches the specified models with query input
  @docs = Elasticsearch::Model.search(query, model_to_search) 
  @facets = @docs.response["facets"]
  
  @pagination = WillPaginate::Collection.create(pagenum, 30, @docs.response.hits.total) do |pager|
    pager.replace @docs
  end
  @docs = @docs.response["hits"]["hits"]
end