Class: Elasticated::Repository

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/elasticated/repository.rb,
lib/elasticated/repository/search.rb,
lib/elasticated/repository/normal_search.rb,
lib/elasticated/repository/scroll_search.rb,
lib/elasticated/repository/resumable_search.rb,
lib/elasticated/repository/intelligent_search.rb,
lib/elasticated/repository/scan_scroll_search.rb,
lib/elasticated/repository/single_page_search.rb

Direct Known Subclasses

PartitionedRepository

Defined Under Namespace

Classes: IntelligentSearch, NormalSearch, ResumableSearch, ScanScrollSearch, ScrollSearch, Search, SinglePageSearch

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

delegated

Constructor Details

#initialize(opts = {}) ⇒ Repository

Returns a new instance of Repository.



10
11
12
# File 'lib/elasticated/repository.rb', line 10

def initialize(opts={})
  self.client = Client.new opts
end

Instance Attribute Details

#clientObject

child can implement ‘execute(action, query, opts)’ child can implement ‘prepare(action, document, opts)’



8
9
10
# File 'lib/elasticated/repository.rb', line 8

def client
  @client
end

Instance Method Details

#create_percolator(query, opts = {}) ⇒ Object



46
47
48
# File 'lib/elasticated/repository.rb', line 46

def create_percolator(query, opts={})
  prepare_percolator :create_percolator, query, opts
end

#delete_by(query, opts = {}) ⇒ Object



30
31
32
# File 'lib/elasticated/repository.rb', line 30

def delete_by(query, opts={})
  execute :delete, query, opts
end

#execute_aggregated_search(query, opts = {}) ⇒ Object



26
27
28
# File 'lib/elasticated/repository.rb', line 26

def execute_aggregated_search(query, opts={})
  execute :aggregated_search, query, opts
end

#execute_aggregations(query, opts = {}) ⇒ Object



18
19
20
# File 'lib/elasticated/repository.rb', line 18

def execute_aggregations(query, opts={})
  execute :aggregations, query, opts
end

#execute_count(query, opts = {}) ⇒ Object



22
23
24
# File 'lib/elasticated/repository.rb', line 22

def execute_count(query, opts={})
  execute :count, query, opts
end

#execute_search(query, opts = {}) ⇒ Object



14
15
16
# File 'lib/elasticated/repository.rb', line 14

def execute_search(query, opts={})
  execute :search, query, opts
end

#exists?(query, opts = {}) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/elasticated/repository.rb', line 34

def exists?(query, opts={})
  execute_count(query, opts) > 0
end

#index_document(document, opts = {}) ⇒ Object



38
39
40
# File 'lib/elasticated/repository.rb', line 38

def index_document(document, opts={})
  prepare :index, document, opts
end

#percolate(document, opts = {}) ⇒ Object



50
51
52
# File 'lib/elasticated/repository.rb', line 50

def percolate(document, opts={})
  prepare_percolator :percolate, document, opts
end

#prepare_search(query, opts = {}) ⇒ Object



54
55
56
# File 'lib/elasticated/repository.rb', line 54

def prepare_search(query, opts={})
  execute :prepare_search, query, opts
end

#restore_search(scroll_id) ⇒ Object



58
59
60
# File 'lib/elasticated/repository.rb', line 58

def restore_search(scroll_id)
  ResumableSearch.from_scroll_id self, scroll_id
end

#update_document(document, opts = {}) ⇒ Object



42
43
44
# File 'lib/elasticated/repository.rb', line 42

def update_document(document, opts={})
  prepare :update, document, opts
end