无法使用 JDBC River 从 ElasticSearch 获取任何结果



我根本不知道如何使用这个插件。
我正在运行此curl

curl -XPUT 'localhost:9200/_river/faycare_kids/_meta' -d '{
  "jdbc":{
      "driver" : "org.postgresql.Driver",
      "url" : "jdbc:postgresql://localhost:5432/faycare",
      "user" : "faycare",
      "password" : "password",
      "strategy" : "simple",
      "poll" : "5s",
      "scale" : 0,
      "autocommit" : true,
      "fetchsize" : 10,
      "index" : "faycare",
      "type" : "kid",
      "max_rows" : 0,
      "max_retries" : 3,
      "max_retries_wait" : "10s",
      "sql"   : "SELECT kid.id as _id,kid.first_name,kid.last_name FROM kid;"
  }
}'

它返回:

{"ok":true,"_index":"_river","_type":"faycare_kids","_id":"_meta","_version":1}

如何搜索/获取/查看我的数据?

我如何知道是否有任何内容被索引?

我尝试了很多东西:

curl -XGET 'localhost:9200/_river/faycare_kids/_search?pretty&q=*'

这为我提供了有关_river的信息

curl -XGET 'localhost:9200/faycare/kid/_search?pretty&q=*'

这告诉我:"error" : "IndexMissingException[[faycare] missing]"

我正在运行sudo service elasticsearch start以在后台运行它。

首先,我会安装 elasticsearch head,它对于检查您的集群非常有用。

您可以获取所有指数的统计信息:

curl -XGET 'http://localhost:9200/_all/_status'

您可以检查索引是否存在:

curl -XHEAD 'http://localhost:9200/myindex'

您应该能够像这样搜索所有索引:

  curl -XGET 'localhost:9200/_all/_search?q=*'

如果什么都没有出现,你的河流可能不工作,我会检查你的日志,看看是否有任何错误出现。

问题在于你设置河流的方式。您可以指定、索引和键入河流应在错误位置批量索引记录的位置。

执行此操作的正确方法是:

curl -XPUT 'localhost:9200/_river/faycare_kids/_meta' -d '{
  "type" : "jdbc",
  "jdbc":{
      "driver" : "org.postgresql.Driver",
      "url" : "jdbc:postgresql://localhost:5432/faycare",
      "user" : "faycare",
      "password" : "password",
      "strategy" : "simple",
      "poll" : "5s",
      "scale" : 0,
      "autocommit" : true,
      "fetchsize" : 10,
      "max_rows" : 0,
      "max_retries" : 3,
      "max_retries_wait" : "10s",
      "sql"   : "SELECT kid.id as _id,kid.first_name,kid.last_name FROM kid;"
  },
  "index":{
      "index" : "faycare",
      "type" : "kid"
  }
}'

我感谢您的所有帮助。elastic-head确实给了我一些见解。显然我只是JSON出了点问题 出于某种原因,当我将 JSON 更改为此时,它起作用了:

curl -XPUT 'localhost:9200/_river/my_jdbc_river/_meta' -d '{
      "type" : "jdbc",
      "jdbc" : {
          "driver" : "org.postgresql.Driver",
          "url" : "jdbc:postgresql://localhost:5432/faycare",
          "user" : "faycare",
          "password" : "hatpants",
          "index" : "jdbc",
          "type" : "jdbc"
          "sql"   : "SELECT kid.id as _id,kid.first_name,kid.last_name FROM kid;"
      }
 }'

我不确定具体需要更改什么才能使这项工作,但它现在确实有效。我猜这是需要添加的外部jdbc。我猜我可以改变内心indextype.

我写了一篇关于使用此插件的快速文章,希望可以为您提供更多见解 - 该帖子位于此处。

最新更新