Class: Elasticband::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticband/search.rb

Class Method Summary collapse

Class Method Details

.parse(query_text, options) ⇒ Object

Parses a query text with options to a Elasticsearch search syntax. See Elasticband::Query.parse and Elasticband::Aggregation.parse options for details.

#### Examples “‘ Search.parse(’foo’, on: :name, group_by: :status)

> {

  query: { match: { name: 'foo' } },
  aggs: { status: { terms: { field: :status } } },
  sort: [{name: 'desc'}, '+created_at']
}

“‘



16
17
18
19
20
21
22
# File 'lib/elasticband/search.rb', line 16

def parse(query_text, options)
  {
    sort: Sort.parse(options),
    query: Query.parse(query_text, options),
    aggs: Aggregation.parse(options)
  }.reject { |_, value| value.blank? }
end