Class: Qiita::Elasticsearch::HierarchalToken

Inherits:
Token
  • Object
show all
Defined in:
lib/qiita/elasticsearch/hierarchal_token.rb

Instance Attribute Summary

Attributes inherited from Token

#field_name, #options, #term

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 Method Details

#to_hashHash

Returns:

  • (Hash)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/qiita/elasticsearch/hierarchal_token.rb', line 7

def to_hash
  {
    "bool" => {
      "should" => [
        {
          "prefix" => {
            @field_name => proper_cased_term + "/",
          },
        },
        {
          "term" => {
            @field_name => proper_cased_term,
          },
        },
      ],
    },
  }
end