gpt4 book ai didi

json - JDBC、Elasticsearch 和 Postgresql Json 数据类型

转载 作者:行者123 更新时间:2023-11-29 11:50:20 24 4
gpt4 key购买 nike

  • PostgreSQL:9.3.2
    • Elasticsearch :0.90
    • jprante/elasticsearch-river-jdbc : 2.2.2
    • postgresql JDBC : 9.3-1100 JDBC 41

我正在尝试使用 elasticsearch river 将 postgresql Json 数据类型列放入 elasticsearch。

这里是创建的河流

curl -XPUT 'localhost:9200/_river/business_river/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"driver" : "org.postgresql.Driver",
"url" : "jdbc:postgresql://localhost:5432/business",
"user" : "postgres",
"password" : "",
"sql" : "select id, active, companies->'sic'->>'national_number' AS sic, companies->'names'->>'name' AS name, companies->'address'->>'country' AS country from businesses.business",
"index" : "business",
"type" : "jdbc"
}
}'

河流提示“名称”列不存在!!!查询在 Postgresql 中有效这导致我认为 Json 数据类型还不被 JDBC 或河流支持。

这里是完整的信息

[2014-01-13 07:47:27,919][INFO ][org.xbib.elasticsearch.river.jdbc.JDBCRiver] [Brigade] [jdbc][business_river] starting JDBC river: URL [jdbc:postgresql://localhost:5432/business], driver [org.postgresql.Driver], strategy [oneshot], index [jdbc]/[jdbc]
[2014-01-13 07:47:33,281][ERROR][org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] ERROR: column "names" does not exist
Position: 31
org.postgresql.util.PSQLException: ERROR: column "names" does not exist
Position: 31
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:560)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:403)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:283)
at org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverSource.executeQuery(SimpleRiverSource.java:417)
at org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverSource.fetch(SimpleRiverSource.java:241)
at org.xbib.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow.move(SimpleRiverFlow.java:184)
at org.xbib.elasticsearch.river.jdbc.strategy.oneshot.OneShotRiverFlow.run(OneShotRiverFlow.java:38)
at java.lang.Thread.run(Thread.java:744)

最佳答案

感谢 Craig Ringer 指出了真正的问题,我重写了我的河流,将 postgresql json 查询中的简单引号替换为“\u0027”,现在它工作得很好

关于json - JDBC、Elasticsearch 和 Postgresql Json 数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21081196/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com