Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing Ruby code identation

  • Loading branch information...
commit 5f9af24cb107f494cfc2836c6c1422f13b32e0fc 1 parent acbb841
Mohamed Magdy authored
Showing with 27 additions and 27 deletions.
  1. +27 −27 Ruby/search_with_tire.rb
View
54 Ruby/search_with_tire.rb
@@ -1,31 +1,31 @@
- def self.search(params)
- query = "#{params[:field] || 'name'}:#{params[:q]}"
- tire.search(load: params[:load]) do
- # Query
- query { string query, default_operator: 'AND' } if params[:q].present?
-
- # Query filters
+def self.search(params)
+ query = "#{params[:field] || 'name'}:#{params[:q]}"
+ tire.search(load: params[:load]) do
+ # Query
+ query { string query, default_operator: 'AND' } if params[:q].present?
+
+ # Query filters
+ if params[:filter][:filter_value]
+ filter :term, params[:filter][:filter_field] => params[:filter][:filter_value]
+ else # If no value is passed then consider it as a missing (null valued) parameter
+ filter :missing, field: params[:filter][:filter_field]
+ end if params[:filter].present?
+
+ # Query size
+ size params[:size] || AppConfig.search_size
+
+ # Sorting results by exact name
+ sort { by :exact_name, 'asc' }
+
+ # Facets
+ facet('initials', global: true) do
+ terms :starting_character, size: (params[:size] || AppConfig.search_size)
+
if params[:filter][:filter_value]
- filter :term, params[:filter][:filter_field] => params[:filter][:filter_value]
+ facet_filter :term, params[:filter][:filter_field] => params[:filter][:filter_value]
else # If no value is passed then consider it as a missing (null valued) parameter
- filter :missing, field: params[:filter][:filter_field]
+ facet_filter :missing, field: params[:filter][:filter_field]
end if params[:filter].present?
-
- # Query size
- size params[:size] || AppConfig.search_size
-
- # Sorting results by exact name
- sort { by :exact_name, 'asc' }
-
- # Facets
- facet('initials', global: true) do
- terms :starting_character, size: (params[:size] || AppConfig.search_size)
-
- if params[:filter][:filter_value]
- facet_filter :term, params[:filter][:filter_field] => params[:filter][:filter_value]
- else # If no value is passed then consider it as a missing (null valued) parameter
- facet_filter :missing, field: params[:filter][:filter_field]
- end if params[:filter].present?
- end
end
- end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.