Class: Elasticated::Repository::IntelligentSearch

Inherits:
Search
  • Object
show all
Includes:
Mixins::Configurable
Defined in:
lib/elasticated/repository/intelligent_search.rb

Instance Attribute Summary

Attributes inherited from Search

#aggregated, #opts, #query, #repository

Instance Method Summary collapse

Methods included from Mixins::Configurable

delegated

Methods inherited from Search

#initialize

Constructor Details

This class inherits a constructor from Elasticated::Repository::Search

Instance Method Details

#best_search_methodObject

if the query is aggregated and the search strategy is a scroll-like alternative, we must do a 2-step search process



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/elasticated/repository/intelligent_search.rb', line 21

def best_search_method
  if query.limited? && !query.heavy_for?(repository)
    SinglePageSearch.new repository, query, aggregated, opts
  else
    if query.offset?
      NormalSearch.new repository, query, aggregated, opts
    else
      if query.sorted?
        ScrollSearch.new repository, query, aggregated, opts
      else
        ScanScrollSearch.new repository, query, aggregated, opts
      end
    end
  end
end

#executeObject



37
38
39
40
41
42
# File 'lib/elasticated/repository/intelligent_search.rb', line 37

def execute
  search_method = best_search_method
  search_method_name = Helpers.unscoped_class_name search_method.class
  log.debug "#{search_method_name} selected as best search method for query #{query.build.to_json}"
  search_method.execute
end