Class: WinewooCore::Services::Finders::Wines::ElasticsearchWinesFinder

Inherits:
WinesFinder
  • Object
show all
Defined in:
lib/winewoo_core/services/finders/wines/elasticsearch_wines_finder.rb

Instance Method Summary collapse

Methods inherited from WinesFinder

#initialize

Constructor Details

This class inherits a constructor from WinewooCore::Services::Finders::Wines::WinesFinder

Instance Method Details

#findObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/winewoo_core/services/finders/wines/elasticsearch_wines_finder.rb', line 4

def find
  Rails.logger.info "WINEWOO ELASTIC"

  page = (@page || 1).to_i
  per_page = (@per_page || Kaminari::config.default_per_page).to_i

  searcher = WinewooCore::Services::ElasticSearch::WinesServices.new
  wines = searcher.fetch_wines(@filters.query, page - 1, per_page)

  Rails.logger.info "WINEWOO #{wines.to_json}"

  # TODO find a way to get the total of results from elastic search
  return wines, "search"
end