Class: AzureSearch::IndexSearchOptions
- Inherits:
-
Object
- Object
- AzureSearch::IndexSearchOptions
- Defined in:
- lib/azure_search/index_search_options.rb
Overview
Represents search options that will be sent along with a search request.
Constant Summary collapse
- SPECIAL_PARAMS =
%w(count filter orderby select top skip).freeze
Instance Method Summary collapse
-
#facets(fs) ⇒ self
Sets the list of fields to facet by.
-
#filter(val) ⇒ self
Sets the structured search expression in standard OData syntax.
-
#highlight(hl) ⇒ self
Sets the set of comma-separated field names used for hit highlights.
-
#highlight_post_tag(hpt) ⇒ self
Sets the string tag that appends to hit highlights (defaults to </em>).
-
#highlight_pre_tag(hpt) ⇒ self
Sets the string tag that appends to hit highlights (defaults to <em>).
-
#include_count(val) ⇒ self
Specifies whether to fetch the total count of results.
-
#minimum_coverage(val) ⇒ self
Sets the percentage of the index that must be covered by a search query.
-
#order_by(val) ⇒ self
Sets the list of comma-separated expressions to sort the results by.
-
#scoring_parameters(params) ⇒ self
Sets the values for each parameter defined in a scoring function.
-
#scoring_profile(sp) ⇒ self
Sets the name of a scoring profile to evaluate match scores for matching documents.
-
#search_fields(val) ⇒ self
Sets the list of comma-separated field names to search for the specified text.
-
#search_mode(mode) ⇒ self
Specifies whether any or all of the search terms must be matched.
-
#select(val) ⇒ self
Sets the list of comma-separated fields to retrieve.
-
#skip(val) ⇒ self
Sets the number of search results to skip.
-
#to_hash ⇒ Hash
Returns the search options as a Hash.
-
#top(val) ⇒ self
Sets the number of search results to retrieve (defaults to 50).
Instance Method Details
#facets(fs) ⇒ self
Sets the list of fields to facet by.
63 64 65 66 67 |
# File 'lib/azure_search/index_search_options.rb', line 63 def facets(fs) raise "facts requires an Array of Strings." unless fs.is_a? Array @facet = fs self end |
#filter(val) ⇒ self
Sets the structured search expression in standard OData syntax.
23 24 25 26 27 |
# File 'lib/azure_search/index_search_options.rb', line 23 def filter(val) raise "filter requires a String." unless val.is_a? String @filter = val self end |
#highlight(hl) ⇒ self
Sets the set of comma-separated field names used for hit highlights.
73 74 75 76 77 |
# File 'lib/azure_search/index_search_options.rb', line 73 def highlight(hl) raise "highlight requires a String." unless hl.is_a? String @highlight = hl self end |
#highlight_post_tag(hpt) ⇒ self
Sets the string tag that appends to hit highlights (defaults to </em>).
93 94 95 96 97 |
# File 'lib/azure_search/index_search_options.rb', line 93 def highlight_post_tag(hpt) raise "highlight_post_tag requires an HTML string." unless has_html?(hpt) @highlightPostTag = hpt self end |
#highlight_pre_tag(hpt) ⇒ self
Sets the string tag that appends to hit highlights (defaults to <em>).
83 84 85 86 87 |
# File 'lib/azure_search/index_search_options.rb', line 83 def highlight_pre_tag(hpt) raise "highlight_pre_tag requires an HTML string." unless has_html?(hpt) @highlightPreTag = hpt self end |
#include_count(val) ⇒ self
Specifies whether to fetch the total count of results.
13 14 15 16 17 |
# File 'lib/azure_search/index_search_options.rb', line 13 def include_count(val) raise "include_count requires a boolean value." unless is_bool?(val) @count = val self end |
#minimum_coverage(val) ⇒ self
Sets the percentage of the index that must be covered by a search query.
153 154 155 156 157 158 |
# File 'lib/azure_search/index_search_options.rb', line 153 def minimum_coverage(val) raise "minimum_coverage requires a Float." unless val.is_a? Float raise "minimum_coverage must be between 0 and 100" unless val.between?(0, 100) @minimumCoverage = val self end |
#order_by(val) ⇒ self
Sets the list of comma-separated expressions to sort the results by.
33 34 35 36 37 |
# File 'lib/azure_search/index_search_options.rb', line 33 def order_by(val) raise "order_by requires a String." unless val.is_a? String @orderby = val self end |
#scoring_parameters(params) ⇒ self
Sets the values for each parameter defined in a scoring function.
113 114 115 116 117 |
# File 'lib/azure_search/index_search_options.rb', line 113 def scoring_parameters(params) raise "scoring_parameters requires an Array of Strings." unless params.is_a? Array @scoringParameter = params self end |
#scoring_profile(sp) ⇒ self
Sets the name of a scoring profile to evaluate match scores for matching documents.
103 104 105 106 107 |
# File 'lib/azure_search/index_search_options.rb', line 103 def scoring_profile(sp) raise "scoring_profile requires a String." unless sp.is_a? String @scoringProfile = sp self end |
#search_fields(val) ⇒ self
Sets the list of comma-separated field names to search for the specified text.
53 54 55 56 57 |
# File 'lib/azure_search/index_search_options.rb', line 53 def search_fields(val) raise "search_fields requires a String." unless val.is_a? String @searchFields = val self end |
#search_mode(mode) ⇒ self
Specifies whether any or all of the search terms must be matched.
143 144 145 146 147 |
# File 'lib/azure_search/index_search_options.rb', line 143 def search_mode(mode) raise "invalid search mode." unless ["any", "all"].include? mode @searchMode = mode self end |
#select(val) ⇒ self
Sets the list of comma-separated fields to retrieve.
43 44 45 46 47 |
# File 'lib/azure_search/index_search_options.rb', line 43 def select(val) raise "select requires a String." unless val.is_a? String @select = val self end |
#skip(val) ⇒ self
Sets the number of search results to skip.
133 134 135 136 137 |
# File 'lib/azure_search/index_search_options.rb', line 133 def skip(val) raise "skip requires an Integer." unless val.is_a? Integer @skip = val self end |
#to_hash ⇒ Hash
Returns the search options as a Hash.
163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/azure_search/index_search_options.rb', line 163 def to_hash hash = {} instance_variables.each {|var| varname = var.to_s.delete("@") if SPECIAL_PARAMS.include? varname hash["$"+varname] = instance_variable_get(var) else hash[varname] = instance_variable_get(var) end } hash end |
#top(val) ⇒ self
Sets the number of search results to retrieve (defaults to 50).
123 124 125 126 127 |
# File 'lib/azure_search/index_search_options.rb', line 123 def top(val) raise "top requires an Integer." unless val.is_a? Integer @top = val self end |