How to implement full text search using Elasticsearch in Rails?

216 views Asked by At

I am following this article to implement full text search using Elasticsearch in my Rails application but I am getting this error

/.rvm/gems/ruby-2.1.5/gems/rack-1.6.1/lib/rack/builder.rb:49: stack level too deep (SystemStackError)

app/models/article.rb: 
   require 'elasticsearch/model' 
     class Article < ActiveRecord::Base 
      include Elasticsearch::Model 
      include Elasticsearch::Model::Callbacks 
     end 
    Article.import # for auto sync model with elastic search

Whenever, I write Article.import in my article.rb model.

1

There are 1 answers

1
fengd On

Try define method to_indexed_json, which tell ES how your JSON serialisation model is.

take a look at this question, elasticsearch mapping and to_indexed_json , of which the answer clarify what mapping and indexed_json are.