Method: Qiita::Elasticsearch::MatchableToken#to_hash

Defined in:
lib/qiita/elasticsearch/matchable_token.rb

#to_hashHash

Returns:

  • (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