class Documentation::Searchers::Elasticsearch

Public Instance Methods

delete(page) click to toggle source
# File lib/documentation/searchers/elasticsearch.rb, line 13
def delete(page)
  client.delete(:index => index_name, :type => 'page', :id => page.id)
rescue ::Elasticsearch::Transport::Transport::Errors::NotFound
  false
end
index(page) click to toggle source
# File lib/documentation/searchers/elasticsearch.rb, line 9
def index(page)
  client.index(:index => index_name, :type => 'page', :id => page.id, :body => page_to_hash(page))
end
reset() click to toggle source
# File lib/documentation/searchers/elasticsearch.rb, line 19
def reset
  client.indices.delete(:index => index_name)
end
setup() click to toggle source
# File lib/documentation/searchers/elasticsearch.rb, line 5
def setup
  require 'elasticsearch'
end

Private Instance Methods

client() click to toggle source
# File lib/documentation/searchers/elasticsearch.rb, line 89
def client
  @client ||= ::Elasticsearch::Client.new(options[:client] || {})
end
index_name() click to toggle source
# File lib/documentation/searchers/elasticsearch.rb, line 71
def index_name
  options[:index_name] || 'pages'
end
page_to_hash(page) click to toggle source
# File lib/documentation/searchers/elasticsearch.rb, line 75
def page_to_hash(page)
  {
    :id => page.id,
    :title => page.title,
    :permalink => page.permalink,
    :full_permalink => page.full_permalink,
    :content => page.content,
    :created_at => page.created_at,
    :updated_at => page.updated_at
  }
end