我将在我的rails应用中使用https://github.com/elasticsearch/elasticsearch-rails
进行搜索。我已经通过运行此
DEB file
sudo dpkg -i elasticsearch-1.4.2.deb
我正在学习本教程
http://www.sitepoint.com/full-text-search-rails-elasticsearch/
他们说
Open this url: http://localhost:9200 and you’ll see ElasticSearch respond like so:
{
"status" : 200,
"name" : "Anvil",
"version" : {
"number" : "1.2.1",
"build_hash" : "6c95b759f9e7ef0f8e17f77d850da43ce8a4b364",
"build_timestamp" : "2014-06-03T15:02:52Z",
"build_snapshot" : false,
"lucene_version" : "4.8"
},
"tagline" : "You Know, for Search"
}
但是当我去localhost:9200它会给我This webpage is not available
这是我的elasticsearch.yml
config = {
host: "http://localhost:9200/",
transport_options: {
request: { timeout: 5 }
},
}
if File.exists?("config/elasticsearch.yml")
config.merge!(YAML.load_file("config/elasticsearch.yml").symbolize_keys)
end
Elasticsearch::Model.client = Elasticsearch::Client.new(config)
当我搜索它会给我这个和在视图页面上它没有显示我
Parameters: {"utf8"=>"✓", "authenticity_token"=>"hMQQxSLAckDdmLAIMn8nTPv2BOe8v0l1dtMsfi9TEW4=", "q"=>"qwerty", "commit"=>"Go"}
Admin Load (1.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = 1 ORDER BY "admins"."id" ASC LIMIT 1
***********************************************************
#<Elasticsearch::Model::Response::Response:0x007f0114b48310 @klass=[PROXY] Feed(id: integer, title: string, json_data: text, created_at: datetime, updated_at: datetime, image: string, url: string, user_name: string, user_image: string, slug: string, custom_thumbnail_file_name: string, custom_thumbnail_content_type: string, custom_thumbnail_file_size: integer, custom_thumbnail_updated_at: datetime, custom_user_image_file_name: string, custom_user_image_content_type: string, custom_user_image_file_size: integer, custom_user_image_updated_at: datetime, user_id: integer, front_page_title: string, primary_category: string, status: string, primary_category_title: string, add_description: text, add_short_description: text, is_premium: boolean, is_course: boolean, price: float, supply: text, process: text, body_text: text, link: text, direct_link: text, procedure: text, status_message: string, short_url: string, course_status: string, pinterest_image_file_name: string, pinterest_image_content_type: string, pinterest_image_file_size: integer, pinterest_image_updated_at: datetime, pinterest_image_url: string), @search=#<Elasticsearch::Model::Searching::SearchRequest:0x007f0114b49ad0 @klass=[PROXY] Feed(id: integer, title: string, json_data: text, created_at: datetime, updated_at: datetime, image: string, url: string, user_name: string, user_image: string, slug: string, custom_thumbnail_file_name: string, custom_thumbnail_content_type: string, custom_thumbnail_file_size: integer, custom_thumbnail_updated_at: datetime, custom_user_image_file_name: string, custom_user_image_content_type: string, custom_user_image_file_size: integer, custom_user_image_updated_at: datetime, user_id: integer, front_page_title: string, primary_category: string, status: string, primary_category_title: string, add_description: text, add_short_description: text, is_premium: boolean, is_course: boolean, price: float, supply: text, process: text, body_text: text, link: text, direct_link: text, procedure: text, status_message: string, short_url: string, course_status: string, pinterest_image_file_name: string, pinterest_image_content_type: string, pinterest_image_file_size: integer, pinterest_image_updated_at: datetime, pinterest_image_url: string), @options={}, @definition={:index=>"feeds", :type=>"feed", :q=>"qwerty"}>>
感谢任何帮助
答案 0 :(得分:0)
请参阅有关debian软件包http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-service.html#_debian_ubuntu
设置的指南默认情况下Elasticsearch无法启动,当作为包安装时,您需要通过运行
手动启动它 /etc/init.d/elasticsearch start
如果您想在启动时启动Elasticsearch,请添加此
sudo update-rc.d elasticsearch defaults 95 10