gpt4 book ai didi

json - 如何在 elasticsearch river 插件的帮助下从 elasticsearch 服务器索引 couchdb,从而获取 JSON 数据

转载 作者:行者123 更新时间:2023-12-01 09:33:04 25 4
gpt4 key购买 nike

我正在研究数据的图形表示。该图接受 JSON 数据,因此我需要从 couchdb 中获取所需的数据。我正在使用 elasticsearch 服务器为 couchdb 建立索引,从而检索所需的数据。我正在使用 elasticsearch river 插件将 couchdb 和 elasticsearch 服务器放在一起。

我已经创建了 CouchDB 数据库“testdb”并为其创建了一些测试文档。使用数据库设置 elasticsearch。在通过使用默认搜索条件编写 CURl GET 命令来测试相同内容时,我们必须获得大于 0 的“总命中数”,并且“命中数”必须具有针对搜索条件的一些响应值。但是我们得到的“总点击数”为 0 和“点击数”:[](即空值)

我遵循的程序。

1) 下载并安装最新版本的couchdb

2) 已验证 CouchDB 正在运行

curl localhost:5984

I got response that starts with:

{"couchdb":"Welcome"...

3) 下载ElasticSearch并安装服​​务

service.bat install

curl http://127.0.0.1:9200

I got response as


{ "ok" : true, "status" : 200,.....

4) 为 ElasticSearch 1.4.2 安装了 CouchDB River 插件

plugin -install elasticsearch/elasticsearch-river-couchdb/2.4.1

5) 创建 CouchDB 数据库和 ElasticSearch 索引

curl -X PUT "http://127.0.0.1:5984/testdb"

6) 创建一些测试文档:

curl -X PUT "http://127.0.0.1:5984/testdb/1" -d "{\"name\":\"My Name 1\"}"
curl -X PUT "http://127.0.0.1:5984/testdb/2" -d "{\"name\":\"My Name 2\"}"
curl -X PUT "http://127.0.0.1:5984/testdb/3" -d "{\"name\":\"My Name 3\"}"
curl -X PUT "http://127.0.0.1:5984/testdb/4" -d "{\"name\":\"My Name 4\"}"

7) 使用数据库设置 ElasticSearch

curl -X PUT "127.0.0.1:9200/_river/testdb/_meta" -d "{ \"type\" : \"couchdb\", \"couchdb\" : { \"host\" : \"localhost\", \"port\" : 5984, \"db\" : \"testdb\", \"filter\" : null }, \"index\" : { \"index\" : \"testdb\", \"type\" : \"testdb\", \"bulk_size\" : \"100\", \"bulk_timeout\" : \"10ms\" } }"

8) 测试一下

curl "http://127.0.0.1:9200/testdb/testdb/_search?pretty=true"

on testing we should get this




{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 4,
"max_score" : 1.0,
"hits" : [ {
"_index" : "testdb",
"_type" : "testdb",
"_id" : "4",
"_score" : 1.0, "_source" : {"_rev":"1-7e9376fc8bfa6b8c8788b0f408154584","_id":"4","name":"My Name 4"}
}, {
"_index" : "testdb",
"_type" : "testdb",
"_id" : "1",
"_score" : 1.0, "_source" : {"_rev":"1-87386bd54c821354a93cf62add449d31","_id":"1","name":"My Name"}
}, {
"_index" : "testdb",
"_type" : "testdb",
"_id" : "2",
"_score" : 1.0, "_source" : {"_rev":"1-194582c1e02d84ae36e59f568a459633","_id":"2","name":"My Name 2"}
}, {
"_index" : "testdb",
"_type" : "testdb",
"_id" : "3",
"_score" : 1.0, "_source" : {"_rev":"1-62a53c50e7df02ec22973fc802fb9fc0","_id":"3","name":"My Name 3"}
} ]
}
}

但是我得到了这样的东西

{
"error" : "IndexMissingException[[testdb] missing]",
"status" : 404
}

最佳答案

这个 curl 字符串不需要额外的 testb。这:

curl "http://127.0.0.1:9200/testdb/testdb/_search?pretty=true"

应该是这样的:

curl 'http://localhost/testdb/_search?pretty=true'

您可以通过运行以下命令并确保您的搜索是针对您的一个索引来查看您的所有内容:

curl -X GET 'localhost:9200/_cat/indices'

关于json - 如何在 elasticsearch river 插件的帮助下从 elasticsearch 服务器索引 couchdb,从而获取 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28417224/

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