Class: JayAPI::Elasticsearch::QueryBuilder::QueryClauses::MatchPhrase

Inherits:
QueryClause
  • Object
show all
Defined in:
lib/jay_api/elasticsearch/query_builder/query_clauses/match_phrase.rb

Overview

Represents a Match Phrase query in Elasticsearch Documentation for this type of query can be found here: www.elastic.co/guide/en/elasticsearch/reference/7.9/query-dsl-match-query-phrase.html#query-dsl-match-query-phrase

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, phrase:) ⇒ MatchPhrase

Returns a new instance of MatchPhrase.

Parameters:

  • field (String)

    The name of the field to match against

  • phrase (String)

    The phrase to match



17
18
19
20
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/match_phrase.rb', line 17

def initialize(field:, phrase:)
  @field = field
  @phrase = phrase
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/match_phrase.rb', line 13

def field
  @field
end

#phraseObject (readonly)

Returns the value of attribute phrase.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/match_phrase.rb', line 13

def phrase
  @phrase
end

Instance Method Details

#to_hHash

Returns The Hash representation of the Query Clause (in Elasticsearch’s format).

Returns:

  • (Hash)

    The Hash representation of the Query Clause (in Elasticsearch’s format)



24
25
26
27
28
29
30
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/match_phrase.rb', line 24

def to_h
  {
    match_phrase: {
      field => phrase
    }
  }
end