Class: Queries::MatchQueryBuilder
- Inherits:
-
QueryBuilder
- Object
- QueryBuilder
- Queries::MatchQueryBuilder
- Defined in:
- lib/queries/match_query_builder.rb
Constant Summary collapse
- NAME =
@params: analyzer, auto_generate_synonyms_phrase_query, cutoff_frequency, field_name, fuzziness, fuzzy_transposition,
lenient, max_expansions, minimum_should_match, operator, prefix_length, value, zero_terms_query analyzer: analyzer to be used for this query auto_generate_synonyms_phrase_query: The match query supports multi-terms synonym expansion with the synonym_graph token filter. When this filter is used, the parser creates a phrase query for each multi-terms synonyms. For example, the following synonym: "ny, new york" would produce: (ny OR ("new york")) cutoff_frequency: cutoff value in [0..1] (or absolute number >=1) representing the maximum threshold of a terms document frequency to be considered a low frequency term. field_name: name of the field to be queried fuzziness: fuzziness used when evaluated to a fuzzy query type fuzzy_transposition: fuzzy transpositions (ab → ba) are allowed by default but can be disabled by setting fuzzy_transpositions to false max_expansions: max_expansions limit the number of matching docs that will be returned minimum_should_match: minimum number of cases to match in case of or query value: value to be matched in that field in the documents zero_terms_query: If the analyzer used removes all tokens in a query like a stop filter does, the default behavior is to match no documents at all. In order to change that the zero_terms_query option can be used, which accepts none (default) and all which corresponds to a match_all query. fuzzy_prefix_length: prefix length provides the number of characters from beginning that have to be exactly matched
"match"
Instance Method Summary collapse
-
#analyzer(value) ⇒ Object
sets analyzer.
-
#analyzer_expr ⇒ Object
SEARCH ANALYZER ########## return analyzer.
-
#auto_generate_synonyms_phrase_query(value) ⇒ Object
sets auto_generate_synonyms_phrase_query.
-
#auto_generate_synonyms_phrase_query_expr ⇒ Object
AUTO GENERATE SYNONYMS PHRASE QUERY ########## returns auto_generate_synonyms_phrase_query.
-
#cutoff_frequency(value) ⇒ Object
sets cutoff_frequency.
-
#cutoff_frequency_expr ⇒ Object
CUTOFF FREQUENCY ########## returns cutoff_frequency.
-
#field_name_expr ⇒ Object
FIELD NAME ########## returns field_name.
-
#fuzziness(fuzziness) ⇒ Object
sets fuzziness.
-
#fuzziness_expr ⇒ Object
FUZZINESS VALUE ########## returns fuzziness.
-
#fuzzy_prefix_length(value) ⇒ Object
sets prefix_length.
-
#fuzzy_prefix_length_expr ⇒ Object
PREFIX LENGTH ######## returns prefix_length.
-
#fuzzy_transpositions(value) ⇒ Object
sets fuzzy_transpositions.
-
#fuzzy_transpositions_expr ⇒ Object
FUZZY TRANSPOSITIONS ########## returns fuzzy_transpositions.
-
#initialize(field_name:, value: nil) ⇒ MatchQueryBuilder
constructor
A new instance of MatchQueryBuilder.
-
#max_expansions(value) ⇒ Object
sets max_expansions.
-
#max_expansions_expr ⇒ Object
MAX EXPANSIONS ########## returns max_expansions.
-
#minimum_should_match(value) ⇒ Object
sets minimum_should_match.
-
#minimum_should_match_expr ⇒ Object
MINIMUM SHOULD ########## returns minimum_should_match.
- #query ⇒ Object
-
#value_expr ⇒ Object
FIELD VALUE ########## returns value.
-
#zero_terms_query(zero_terms_query) ⇒ Object
sets zero_terms_query.
-
#zero_terms_query_expr ⇒ Object
ZERO TERMS ########## returns zero_terms_query.
Methods inherited from QueryBuilder
Methods included from AttributesReader
Methods included from AbstractQueryBuilder
Constructor Details
#initialize(field_name:, value: nil) ⇒ MatchQueryBuilder
Returns a new instance of MatchQueryBuilder.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/queries/match_query_builder.rb', line 28 def initialize field_name: , value: nil @field_name = field_name @value = value @zero_terms_query = nil @analyzer = nil @auto_generate_synonyms_phrase_query = nil @cutoff_frequency = nil @fuzziness = nil @fuzzy_transpositions = nil @max_expansions = nil @minimum_should_match = nil @operator = nil @prefix_length = nil @zero_terms_query = nil end |
Instance Method Details
#analyzer(value) ⇒ Object
sets analyzer
82 83 84 85 |
# File 'lib/queries/match_query_builder.rb', line 82 def analyzer value @analyzer = value return self end |
#analyzer_expr ⇒ Object
SEARCH ANALYZER ########## return analyzer
78 79 80 |
# File 'lib/queries/match_query_builder.rb', line 78 def analyzer_expr return @analyzer end |
#auto_generate_synonyms_phrase_query(value) ⇒ Object
sets auto_generate_synonyms_phrase_query
94 95 96 97 |
# File 'lib/queries/match_query_builder.rb', line 94 def auto_generate_synonyms_phrase_query value @auto_generate_synonyms_phrase_query = value return self end |
#auto_generate_synonyms_phrase_query_expr ⇒ Object
AUTO GENERATE SYNONYMS PHRASE QUERY ########## returns auto_generate_synonyms_phrase_query
90 91 92 |
# File 'lib/queries/match_query_builder.rb', line 90 def auto_generate_synonyms_phrase_query_expr return @auto_generate_synonyms_phrase_query end |
#cutoff_frequency(value) ⇒ Object
sets cutoff_frequency
106 107 108 109 |
# File 'lib/queries/match_query_builder.rb', line 106 def cutoff_frequency value @cutoff_frequency = value return self end |
#cutoff_frequency_expr ⇒ Object
CUTOFF FREQUENCY ########## returns cutoff_frequency
102 103 104 |
# File 'lib/queries/match_query_builder.rb', line 102 def cutoff_frequency_expr return @cutoff_frequency end |
#field_name_expr ⇒ Object
FIELD NAME ########## returns field_name
66 67 68 |
# File 'lib/queries/match_query_builder.rb', line 66 def field_name_expr return @field_name end |
#fuzziness(fuzziness) ⇒ Object
sets fuzziness
118 119 120 121 |
# File 'lib/queries/match_query_builder.rb', line 118 def fuzziness fuzziness @fuzziness = fuzziness.fuzziness return self end |
#fuzziness_expr ⇒ Object
FUZZINESS VALUE ########## returns fuzziness
114 115 116 |
# File 'lib/queries/match_query_builder.rb', line 114 def fuzziness_expr return @fuzziness end |
#fuzzy_prefix_length(value) ⇒ Object
sets prefix_length
129 130 131 132 |
# File 'lib/queries/match_query_builder.rb', line 129 def fuzzy_prefix_length value @prefix_length = value return self end |
#fuzzy_prefix_length_expr ⇒ Object
PREFIX LENGTH ######## returns prefix_length
125 126 127 |
# File 'lib/queries/match_query_builder.rb', line 125 def fuzzy_prefix_length_expr return @prefix_length end |
#fuzzy_transpositions(value) ⇒ Object
sets fuzzy_transpositions
151 152 153 154 |
# File 'lib/queries/match_query_builder.rb', line 151 def fuzzy_transpositions value @fuzzy_transpositions = value return self end |
#fuzzy_transpositions_expr ⇒ Object
FUZZY TRANSPOSITIONS ########## returns fuzzy_transpositions
147 148 149 |
# File 'lib/queries/match_query_builder.rb', line 147 def fuzzy_transpositions_expr return @fuzzy_transpositions end |
#max_expansions(value) ⇒ Object
sets max_expansions
140 141 142 143 |
# File 'lib/queries/match_query_builder.rb', line 140 def max_expansions value @max_expansions = value return self end |
#max_expansions_expr ⇒ Object
MAX EXPANSIONS ########## returns max_expansions
136 137 138 |
# File 'lib/queries/match_query_builder.rb', line 136 def max_expansions_expr return @max_expansions end |
#minimum_should_match(value) ⇒ Object
sets minimum_should_match
162 163 164 165 |
# File 'lib/queries/match_query_builder.rb', line 162 def minimum_should_match value @minimum_should_match = value return self end |
#minimum_should_match_expr ⇒ Object
MINIMUM SHOULD ########## returns minimum_should_match
158 159 160 |
# File 'lib/queries/match_query_builder.rb', line 158 def minimum_should_match_expr return @minimum_should_match end |
#query ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/queries/match_query_builder.rb', line 44 def query query = {} match_query = {} = self.common_query [:query] = @value [:operator] = @operator if @operator.present? [:analyzer] = @analyzer if @analyzer.present? [:auto_generate_synonyms_phrase_query] = @auto_generate_synonyms_phrase_query if @auto_generate_synonyms_phrase_query.present? [:cutoff_frequency] = @cutoff_frequency if @cutoff_frequency.present? [:fuzzy_prefix_length] = @fuzzy_prefix_length if @fuzzy_prefix_length.present? [:max_expansions] = @max_expansions if @max_expansions.present? [:fuzzy_transpositions] = @fuzzy_transpositions if @fuzzy_transpositions.present? [:minimum_should_match] = @minimum_should_match if @minimum_should_match.present? [:zero_terms_query] = @zero_terms_query if @zero_terms_query.present? [:fuzziness] = @fuzziness if @fuzziness.present? match_query[@field_name.to_s.intern] = query[name.intern] = match_query return query end |
#value_expr ⇒ Object
FIELD VALUE ########## returns value
72 73 74 |
# File 'lib/queries/match_query_builder.rb', line 72 def value_expr return @value end |
#zero_terms_query(zero_terms_query) ⇒ Object
sets zero_terms_query
173 174 175 176 |
# File 'lib/queries/match_query_builder.rb', line 173 def zero_terms_query zero_terms_query @zero_terms_query = zero_terms_query.zero_term return self end |
#zero_terms_query_expr ⇒ Object
ZERO TERMS ########## returns zero_terms_query
169 170 171 |
# File 'lib/queries/match_query_builder.rb', line 169 def zero_terms_query_expr return @zero_terms_query end |