Class: Qiita::Elasticsearch::MatchableToken
- Defined in:
- lib/qiita/elasticsearch/matchable_token.rb
Constant Summary collapse
- RELATIVE_BEST_FIELDS_QUERY_WEIGHT =
0.5
Instance Attribute Summary collapse
-
#default_fields ⇒ Object
writeonly
Sets the attribute default_fields.
-
#field_mapping ⇒ Object
Returns the value of attribute field_mapping.
Attributes inherited from Token
Instance Method Summary collapse
Methods inherited from Token
#downcased?, #downcased_term, #filter?, #initialize, #must?, #must_not?, #negative?, #or?, #positive?, #proper_cased_term, #query?, #quoted?, #sort?, #to_s, #type?
Constructor Details
This class inherits a constructor from Qiita::Elasticsearch::Token
Instance Attribute Details
#default_fields=(value) ⇒ Object (writeonly)
Sets the attribute default_fields
8 9 10 |
# File 'lib/qiita/elasticsearch/matchable_token.rb', line 8 def default_fields=(value) @default_fields = value end |
#field_mapping ⇒ Object
Returns the value of attribute field_mapping.
9 10 11 |
# File 'lib/qiita/elasticsearch/matchable_token.rb', line 9 def field_mapping @field_mapping end |
Instance Method Details
#to_hash ⇒ Hash
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/qiita/elasticsearch/matchable_token.rb', line 12 def to_hash if quoted? build_multi_match_query(type: "phrase") else { "bool" => { "should" => [ build_multi_match_query(type: "phrase"), build_multi_match_query(type: "best_fields", boost: RELATIVE_BEST_FIELDS_QUERY_WEIGHT), ], }, } end end |