我正在尝试使用elasticsearch gem索引一个简单文档,索引创建成功但是当我尝试在更改索引名称后索引一个简单文档(LogEntry)时出现超时错误,尽管与搜索服务器的连接是通过其他命令可以访问,这发生在我的生产环境RHEL而不是我的开发机器Ubuntu
上irb(main):001:0> REPOSITORY.index
=> "ip_logstreams_2014_8_29"
irb(main):002:0> tr = LogEntry.new msgtext: "hello"
=> #<LogEntry:0x0000001dd1dc48 @attributes={:msgtext=>"hello"}>
irb(main):003:0> REPOSITORY.create_index!
2014-08-30 00:52:51 +0200: HEAD http://10.74.123.70:9200/ip_logstreams_2014_8_29 [status:200, request:0.002s, query:n/a]
2014-08-30 00:52:51 +0200: <
=> nil
irb(main):004:0> REPOSITORY.save(tr)
2014-08-30 00:53:00 +0200: POST http://10.74.123.70:9200/ip_logstreams_2014_8_29/log_entry [status:201, request:0.209s, query:n/a]
2014-08-30 00:53:00 +0200: > {"msgtext":"hello"}
2014-08-30 00:53:00 +0200: < {"_index":"ip_logstreams_2014_8_29","_type":"log_entry","_id":"N4XHKXeRTGmZfWql_C5Svw","_version":1,"created":true}
=> {"_index"=>"ip_logstreams_2014_8_29", "_type"=>"log_entry", "_id"=>"N4XHKXeRTGmZfWql_C5Svw", "_version"=>1, "created"=>true}
irb(main):029:0> REPOSITORY.index = "ip_logstreams_2014_8_30"
=> "ip_logstreams_2014_8_30"
irb(main):030:0> REPOSITORY.create_index!
2014-08-30 00:25:52 +0200: HEAD http://10.74.123.70:9200/ip_logstreams_2014_8_30 [status:404, request:0.002s, query:N/A]
2014-08-30 00:25:52 +0200: <
2014-08-30 00:25:52 +0200: [404]
2014-08-30 00:25:52 +0200: PUT http://10.74.123.70:9200/ip_logstreams_2014_8_30 [status:200, request:0.399s, query:n/a]
2014-08-30 00:25:52 +0200: > {"settings":{"number_of_shards":5,"analysis":{"analyzer":{"my_pattern":{"type":"custom","tokenizer":"keyword","filter":["url_ngram","lowercase"]}},"filter":{"url_stop":{"type":"stop","stopwords":["="]},"url_ngram":{"type":"nGram","min_gram":4,"max_gram":40}}}},"mappings":{"log_entry":{"properties":{"msgpriority":{"type":"string","analyzer":"snowball"},"msghostname":{"type":"string","analyzer":"snowball"},"msgtext":{"type":"string","analyzer":"my_pattern"},"msgdatetime":{"type":"date","include_in_all":false}}}}}
2014-08-30 00:25:52 +0200: < {"acknowledged":true}
=> {"acknowledged"=>true}
irb(main):031:0> REPOSITORY.save(tr)
2014-08-30 00:27:26 +0200: [Faraday::TimeoutError] Timeout::Error {:host=>"10.74.123.70", :port=>9200, :protocol=>"http"}
Faraday::TimeoutError: Timeout::Error
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2563:in `read_status_line'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2552:in `read_new'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1320:in `block in transport_request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1317:in `catch'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1317:in `transport_request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1294:in `request'
from /usr/local/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1287:in `block in request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:746:in `start'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1285:in `request'
from /usr/local/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
from /usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:80:in `perform_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
from /usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.9.0/lib/faraday/rack_builder.rb:139:in `build_response'
from /usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.9.0/lib/faraday/connection.rb:377:in `run_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/elasticsearch-transport-1.0.4/lib/elasticsearch/transport/transport/http/faraday.rb:21:in `block in perform_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/elasticsearch-transport-1.0.4/lib/elasticsearch/transport/transport/base.rb:187:in `call'
from /usr/local/lib/ruby/gems/1.9.1/gems/elasticsearch-transport-1.0.4/lib/elasticsearch/transport/transport/base.rb:187:in `perform_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/elasticsearch-transport-1.0.4/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/elasticsearch-transport-1.0.4/lib/elasticsearch/transport/client.rb:102:in `perform_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/elasticsearch-api-1.0.4/lib/elasticsearch/api/actions/index.rb:99:in `index'
from /usr/local/lib/ruby/gems/1.9.1/gems/elasticsearch-persistence-0.1.4/lib/elasticsearch/persistence/repository/store.rb:21:in `save'
from (irb):31
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require
模型
class LogEntry
include Tire::Model::Persistence
attr_accessor :msgtext, :msgdatetime, :msgpriority, :msghostname
attr_reader :attributes
def initialize(attributes={})
@attributes = attributes
end
def to_hash
@attributes
end
end