Permalink
Browse files

Added that Rake tasks use configuration from config.rb, not ENV vars …

…passed on command line; Cleaned up README
  • Loading branch information...
1 parent c192f59 commit 1ef85b961662a26b9fd79fc7214b957762bc1765 @karmi committed Apr 10, 2011
Showing with 27 additions and 20 deletions.
  1. +5 −3 README.markdown
  2. +22 −17 Rakefile
View
@@ -26,9 +26,11 @@ Create and edit the configuration file (be sure to set correct path and index na
Run the following Rake tasks:
- rake index:destroy HIDE_WEBSITE=/path/to/the/cloned/website/repo
- rake index:setup HIDE_WEBSITE=/path/to/the/cloned/website/repo
- rake index:import HIDE_WEBSITE=/path/to/the/cloned/website/repo
+ rake index:destroy
+ rake index:setup
+ rake index:import
+
+You can try out some queries in the browser: <http://localhost:9200/elastic-search-website/_search?pretty=true&q=filter>
There's also a server serving as an endpoint for [Github post-receive hooks](http://help.github.com/post-receive-hooks/).
You can run it as any Rack application, for example:
View
@@ -14,29 +14,34 @@ Rake::TestTask.new(:test) do |test|
end
namespace :index do
- # TODO use the configuration from config.rb instead of using the HIDE_WEBSITE environment variable.
- desc "Remove the ElasticSearch index"
- task :destroy do
- site = Hide::Site.new(ENV['HIDE_WEBSITE'], :pages_directories => ['guide', 'community', 'tutorials', 'videos'])
- indexer = Hide::Indexer.new(site, 'elastic-search-website')
- indexer.destroy!
+ task :prepare do
+ @site = Hide::Site.new(Hide.config(:path), :pages_directories => Hide.config(:directories))
+ @indexer = Hide::Indexer.new(Hide.config(:index_name))
end
- desc "Setup the ElasticSearch index (mapping)"
- task :setup do
- site = Hide::Site.new(ENV['HIDE_WEBSITE'], :pages_directories => ['guide', 'community', 'tutorials', 'videos'])
- indexer = Hide::Indexer.new(site, 'elastic-search-website')
- puts indexer.setup() ? 'Created index with mapping' : 'Index already exists'
+ desc "Delete the ElasticSearch index"
+ task :destroy => :prepare do
+ if @indexer.destroy!
+ puts "Deleted index '#{Hide.config(:index_name)}'"
+ else
+ puts "Error deleting index"
+ end
end
- desc "Import whole website into ElasticSearch"
- task :import do
- site = Hide::Site.new(ENV['HIDE_WEBSITE'], :pages_directories => ['guide', 'community', 'tutorials', 'videos'])
- indexer = Hide::Indexer.new(site, 'elastic-search-website')
+ desc "Setup the ElasticSearch index with proper mapping"
+ task :setup => :prepare do
+ if @indexer.setup
+ puts "Created index '#{Hide.config(:index_name)}' with mapping"
+ else
+ puts "Index '#{Hide.config(:index_name)}' already exists"
+ end
+ end
- start = Time.now
- indexer.reindex!
+ desc "Import the website into ElasticSearch index"
+ task :import => :prepare do
+ @start = Time.now
+ @indexer.reindex!
puts "-"*80, "Indexing finished in #{Time.now-start} seconds", ""
end

0 comments on commit 1ef85b9

Please sign in to comment.