I run elastic search in cloud9 with the command
./elasticsearch -E http.port=8081
i then check the status by running curl
curl 127.0.0.1:8081
It returns
{
"name" : "JgfOdbe",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "zELSmBAIStOB1VNaOz1C-Q",
"version" : {
"number" : "6.1.1",
"build_hash" : "bd92e7f",
"build_date" : "2017-12-17T20:23:25.338Z",
"build_snapshot" : false,
"lucene_version" : "7.1.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
Now i create book scaffold and create few books
In books controller i create a test method
def index
@books = Book.search("test", fields: [:title])
end
When i call index action it returns the error
Searchkick::InvalidQueryError in BooksController#index
I have pasted below the error image
I wonder the reason for this error. It seems the syntax is right. I appreciate any help! Thanks!
I believe there are two problems that you need to fix:
Since you're using a different port (8081) than the default (9200), you should set the ELASTICSEARCH_URL
environment variable to that port:
ENV["ELASTICSEARCH_URL"] = "http://localhost:8081"
The documentation about that is here: https://github.com/ankane/searchkick#deployment
After that, you need to get the data from your models to Elasticsearch, by reindexing it with:
Book.reindex
The docs are also here: https://github.com/ankane/searchkick#getting-started