Class: JayAPI::Elasticsearch::QueryBuilder::QueryClauses::Regexp

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

Overview

Represents a Regexp query in Elasticsearch More information about this type of query can be found here: www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, value:) ⇒ Regexp

Returns a new instance of Regexp.

Parameters:

  • field (String, Symbol)

    The field where the regexp query should be applied.

  • value (String, Regexp)

    Terms to be found in field



18
19
20
21
22
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/regexp.rb', line 18

def initialize(field:, value:)
  super()
  @field = field
  @value = value
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



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

def field
  @field
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#to_hHash

Returns The Hash that represents this query (in Elasticsearch’s format).

Returns:

  • (Hash)

    The Hash that represents this query (in Elasticsearch’s format)



26
27
28
29
30
31
32
33
34
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/regexp.rb', line 26

def to_h
  {
    regexp: {
      field => {
        value: value
      }
    }
  }
end