Class: AWSCloudSearch::SearchRequest
- Inherits:
-
Object
- Object
- AWSCloudSearch::SearchRequest
- Defined in:
- lib/aws_cloud_search/search_request.rb
Instance Attribute Summary collapse
-
#bq ⇒ Object
Returns the value of attribute bq.
-
#facet ⇒ Object
Returns the value of attribute facet.
-
#facet_constraints ⇒ Object
Returns the value of attribute facet_constraints.
-
#facet_sort ⇒ Object
Returns the value of attribute facet_sort.
-
#facet_top_n ⇒ Object
Returns the value of attribute facet_top_n.
-
#q ⇒ Object
Returns the value of attribute q.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#results_type ⇒ Object
Returns the value of attribute results_type.
-
#return_fields ⇒ Object
Returns the value of attribute return_fields.
-
#size ⇒ Object
Returns the value of attribute size.
-
#start ⇒ Object
Returns the value of attribute start.
-
#t ⇒ Object
Returns the value of attribute t.
Instance Method Summary collapse
-
#add_facet_constraints(field, constraints) ⇒ Object
Specifies the facet constraints for a field.
-
#add_facet_sort(field, sort) ⇒ Object
Specifies how to sort a facet field.
-
#add_facet_top_n(field, top_n) ⇒ Object
Specifies how many facet constraints to return.
-
#add_t(field, t_from, t_to) ⇒ Object
Restricts the records returned based on the values from the rank expression.
-
#initialize ⇒ SearchRequest
constructor
A new instance of SearchRequest.
-
#to_hash ⇒ Hash
Returns the hash of all the values for this SearchRequest.
Constructor Details
#initialize ⇒ SearchRequest
Returns a new instance of SearchRequest.
7 8 9 |
# File 'lib/aws_cloud_search/search_request.rb', line 7 def initialize @facet_constraints, @facet_sort, @facet_top_n, @t = {}, {}, {}, {} end |
Instance Attribute Details
#bq ⇒ Object
Returns the value of attribute bq.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def bq @bq end |
#facet ⇒ Object
Returns the value of attribute facet.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def facet @facet end |
#facet_constraints ⇒ Object
Returns the value of attribute facet_constraints.
5 6 7 |
# File 'lib/aws_cloud_search/search_request.rb', line 5 def facet_constraints @facet_constraints end |
#facet_sort ⇒ Object
Returns the value of attribute facet_sort.
5 6 7 |
# File 'lib/aws_cloud_search/search_request.rb', line 5 def facet_sort @facet_sort end |
#facet_top_n ⇒ Object
Returns the value of attribute facet_top_n.
5 6 7 |
# File 'lib/aws_cloud_search/search_request.rb', line 5 def facet_top_n @facet_top_n end |
#q ⇒ Object
Returns the value of attribute q.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def q @q end |
#rank ⇒ Object
Returns the value of attribute rank.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def rank @rank end |
#results_type ⇒ Object
Returns the value of attribute results_type.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def results_type @results_type end |
#return_fields ⇒ Object
Returns the value of attribute return_fields.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def return_fields @return_fields end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def size @size end |
#start ⇒ Object
Returns the value of attribute start.
4 5 6 |
# File 'lib/aws_cloud_search/search_request.rb', line 4 def start @start end |
#t ⇒ Object
Returns the value of attribute t.
5 6 7 |
# File 'lib/aws_cloud_search/search_request.rb', line 5 def t @t end |
Instance Method Details
#add_facet_constraints(field, constraints) ⇒ Object
Specifies the facet constraints for a field
14 15 16 |
# File 'lib/aws_cloud_search/search_request.rb', line 14 def add_facet_constraints(field, constraints) @facet_constraints["facet-#{field}-constraints"] = constraints end |
#add_facet_sort(field, sort) ⇒ Object
Specifies how to sort a facet field.
21 22 23 |
# File 'lib/aws_cloud_search/search_request.rb', line 21 def add_facet_sort(field, sort) @facet_sort["facet-#{field}-sort"] = sort end |
#add_facet_top_n(field, top_n) ⇒ Object
Specifies how many facet constraints to return.
28 29 30 31 |
# File 'lib/aws_cloud_search/search_request.rb', line 28 def add_facet_top_n(field, top_n) raise ArgumentError.new("top_n must be of type Integer") unless top_n.kind_of? Integer @facet_top_n["facet-#{field}-top-n"] = top_n end |
#add_t(field, t_from, t_to) ⇒ Object
Restricts the records returned based on the values from the rank expression. The t-field value is a range.
37 38 39 40 41 |
# File 'lib/aws_cloud_search/search_request.rb', line 37 def add_t(field, t_from, t_to) raise ArgumentError.new("Range must have a beginning or ending value or both.") if t_from.nil? and t_to.nil? raise ArgumentError.new("Range values must be of type Integer") unless t_from.kind_of? Integer and t_to.kind_of? Integer @t["t-#{field}"] = "#{t_from}..#{t_to}" end |
#to_hash ⇒ Hash
Returns the hash of all the values for this SearchRequest. Useful for creating URL params.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/aws_cloud_search/search_request.rb', line 45 def to_hash hash = {} hash['q'] = @q unless @q.nil? hash['bq'] = @bq unless @bq.nil? hash['rank'] = @rank unless @rank.nil? hash['size'] = @size unless @size.nil? hash['start'] = @start unless @start.nil? hash['results-type'] = @results_type unless @results_type.nil? hash['return-fields'] = @return_fields.join(',') unless @return_fields.nil? hash['facet'] = @facet unless @facet.nil? hash.merge(@facet_constraints).merge(@facet_sort).merge(@facet_top_n).merge(@t) end |