ElasticSearch Rails 3 Part 1

add to Gamefile

gem 'tire'


def index
  @articles = Article.search(params)


include Tire::Model::Search
include Tire::Model::Callbacks

def self.search(params)
  tire.search(load: true) do
    query { string params[:query], default_operator: "AND" } if params[:query].present?
    filter :range, published_at: {lte: Time.zone.now}


<%= form_tag articles_path, method: :get do %>
    <%= text_field_tag :query, params[:query] %>
    <%= submit_tag "Search", name: nil %>
<% end %>

About me
Interested about Ruby on Rails

One Response to ElasticSearch Rails 3 Part 1

  1. Hey there! My spouse and I frequently publish guest articles for other website owners to help gain exposure to
    our work, as well as provide fantastic articles to weblog
    owners. It really is a win win situation! If you are interested feel
    free to contact me at: ariellawler@freenet.de so we
    may communicate further. Thank you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: