Class: Search
- Inherits:
-
Object
- Object
- Search
- Defined in:
- backend/app/model/search.rb,
frontend/app/models/search.rb
Class Method Summary (collapse)
-
+ (Object) all(repo_id, criteria)
-
+ (Object) for_type(repo_id, type, criteria)
-
+ (Object) global(criteria, type)
-
+ (Object) search(params, repo_id)
Class Method Details
+ (Object) all(repo_id, criteria)
12 13 14 15 16 17 18 19 |
# File 'frontend/app/models/search.rb', line 12 def self.all(repo_id, criteria) criteria["page"] = 1 if not criteria.has_key?("page") search_data = JSONModel::HTTP::get_json("/repositories/#{repo_id}/search", criteria) search_data[:criteria] = criteria SearchResultData.new(search_data) end |
+ (Object) for_type(repo_id, type, criteria)
5 6 7 8 9 |
# File 'frontend/app/models/search.rb', line 5 def self.for_type(repo_id, type, criteria) criteria['type[]'] = Array(type) Search.all(repo_id, criteria) end |
+ (Object) global(criteria, type)
22 23 24 25 26 27 28 29 |
# File 'frontend/app/models/search.rb', line 22 def self.global(criteria, type) criteria["page"] = 1 if not criteria.has_key?("page") search_data = JSONModel::HTTP::get_json("/search/#{type}", criteria) search_data[:criteria] = criteria search_data[:type] = type SearchResultData.new(search_data) end |
+ (Object) search(params, repo_id)
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 |
# File 'backend/app/model/search.rb', line 4 def self.search(params, repo_id) show_suppressed = !RequestContext.get(:enforce_suppression) show_published_only = RequestContext.get(:current_username) === User.PUBLIC_USERNAME Log.debug(params.inspect) query = if params[:q] Solr::Query.create_keyword_search(params[:q]) elsif params[:aq] && params[:aq]['query'] Solr::Query.create_advanced_search(params[:aq]) else Solr::Query.create_match_all_query end query.pagination(params[:page], params[:page_size]). set_repo_id(repo_id). set_record_types(params[:type]). show_suppressed(show_suppressed). show_published_only(show_published_only). set_excluded_ids(params[:exclude]). set_filter_terms(params[:filter_term]). set_simple_filters(params[:simple_filter]). set_facets(params[:facet]). set_sort(params[:sort]). set_root_record(params[:root_record]). highlighting(params[:hl]) Solr.search(query) end |