Class: Dina::SearchCount

Inherits:
BaseSearch show all
Defined in:
lib/dina/search/search_count.rb

Class Method Summary collapse

Methods inherited from BaseSearch

endpoint, index_name, verify_ssl

Methods inherited from BaseModel

custom_headers, find_by_group, #initialize, properties, site

Constructor Details

This class inherits a constructor from Dina::BaseModel

Class Method Details

.endpoint_pathObject



6
7
8
# File 'lib/dina/search/search_count.rb', line 6

def self.endpoint_path
  "search-api/search-ws/count"
end

.execute(index:, payload: { query: { match_all: {} }}) ⇒ Integer

Executes an count search

> Example: {bool: {filter: {term: {“data.attributes.group”: “dao”}}}}

Parameters:

  • index (String)

    the index, accepted value is one of “agent”, “material_sample”, “object_store”

  • payload (Hash) (defaults to: { query: { match_all: {} }})

    the Elasticsearch query hash

Returns:

  • (Integer)

    the count of items in the index according to the query/filter



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

def self.execute(index:, payload: { query: { match_all: {} }})
  params = {
    indexName: index_name(index: index)
  }
  super(params.compact, method: :post, payload: payload)[:count]
end