小编man*_*nsk的帖子

jprante elasticsearch jdbc river更改日期值

我试图使用jprante的elasticsearch jdbc河索引elasticsearch中的 mysql记录.我刚刚注意到日期字段中的值在索引中发生了变化.

制图:

content_date:{
  "type":"date"
}
Run Code Online (Sandbox Code Playgroud)

content_date mysql中记录的字段 - > 2012-10-06 02:11:30

在运行jdbc河之后....

content_date 弹性搜索中相同记录的字段 - > 2012-10-05T20:41:30Z

河:

curl -XPUT 'localhost:9200/_riv_index/_riv_type/_meta' -d '{
    "type" : "jdbc",
    "jdbc" : {
        "driver" : "com.mysql.jdbc.Driver",
        "url" : "jdbc:mysql://localhost:3306/db",
        "user" : "user",
        "password" : "password",
        "sql" : "select * from table where id=2409",
        "poll" : "1d",
        "versioning" : false
    },
    "index" : {
        "index" : "myindex",
        "type" : "mytype"
    }
}'
Run Code Online (Sandbox Code Playgroud)

日期格式的更改是可以接受的,但为什么日期值会更改?这条河正在为mysql记录的日期添加utc时差并将其保存在elasticsearch中.如何停止此时间转换?

jdbc elasticsearch elasticsearch-jdbc-river

5
推荐指数
1
解决办法
979
查看次数

使用rest-client ruby​​ gem在elasticsearch get请求中传递json数据

如何使用rest client 执行以下查询(在doc中给出).

curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}
'
Run Code Online (Sandbox Code Playgroud)

我试过这样做:

q = '{
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}
'

r = JSON.parse(RestClient.get('http://localhost:9200/twitter/tweet/_search', q))
Run Code Online (Sandbox Code Playgroud)

这引发了一个错误:

in `process_url_params': undefined method `delete_if' for #<String:0x8b12e18>     (NoMethodError)
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient/request.rb:40:in `initialize'
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `new'
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient.rb:68:in `get'
    from get_check2.rb:12:in `<main>'
Run Code Online (Sandbox Code Playgroud)

当我使用相同的时候RestClient.post,它给了我正确的结果!但是elasticsearch doc XGET在curl命令中使用搜索查询而不是XPOST.如何使该RestClient.get方法工作?

如果有其他/更好的方法来执行此操作,请建议.

ruby rest-client elasticsearch

3
推荐指数
1
解决办法
4559
查看次数