środa, 30 maja 2012

elasticsearch i tire - instalacja oraz uruchomienie testowej aplikacji



Java 6


$ wget https://github.com/flexiondotorg/oab-java6/raw/0.2.1/oab-java6.sh -O oab-java6.sh
$ chmod +x oab-java6.sh
$ sudo ./oab-java6.sh

$ sudo sudo apt-get install sun-java6-jre

Elasticsearch


$ curl -k -L -o elasticsearch-0.19.4.tar.gz https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.4.tar.gz
$ tar -zxvf elasticsearch-0.19.4.tar.gz
$ ./elasticsearch-0.19.4/bin/elasticsearch -f


Tire and searchapp

rails new searchapp -m https://raw.github.com/karmi/tire/master/examples/rails-application-template.rb
#Gemfile
gem 'kaminari'

#app/models/article.rb
class Article < ActiveRecord::Base
  attr_accessible :title, :content, :published_on
  include Tire::Model::Search
  include Tire::Model::Callbacks
end

#app/controllers/articles_controller.rb
  def search
    @articles = Article.search params[:q], :page => (params[:page] || 1), :per_page => 1

    render :action => "index"
  end

#app/views/articles/index.html.erb
<%= paginate @articles %>



Brak komentarzy:

Prześlij komentarz