加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – IndexMissingException [[wham]缺失

发布时间:2020-12-13 15:56:56 所属栏目:百科 来源:网络整理
导读:浏览:http://127.0.0.1:9200 / wham / _search 给我: { "error": "IndexMissingException[[wham] missing]","status": 404} 我根据这些文件设置了所有内容: http://blog.comperiosearch.com/blog/2014/01/30/elasticsearch-indexing-sql-databases-the-
浏览:http://127.0.0.1:9200 / wham / _search
给我:

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

我根据这些文件设置了所有内容:

> http://blog.comperiosearch.com/blog/2014/01/30/elasticsearch-indexing-sql-databases-the-easy-way/
> https://github.com/jprante/elasticsearch-river-jdbc
> https://github.com/jprante/elasticsearch-river-jdbc/wiki/Step-by-step-recipe-for-setting-up-the-river-with-PostgreSQL
> How to use Elastic Search on top of a pre-existing SQL Database?

最后一个是目前最有帮助的.
那很难过,我通过curl使用了两个不同的“设置”查询来创建我的河流:

curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
  "type": "jdbc","jdbc": {
    "url": "jdbc:postgresql://localhost:5432/testdb","user": "postgres","password": "passywordu","index": "source","type": "wham","sql": "select * from testtable;"
  }
}'

然后我尝试了这是上面最后一个链接的修改版本.

curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
  "type": "jdbc","jdbc": {
    "strategy": "simple","poll": "5s","scale": 0,"autocommit": false,"fetchsize": 10,"max_rows": 0,"max_retries": 3,"max_retries_wait": "10s","url": "jdbc:postgresql://localhost:5432/testdb","sql": "select * from testtable","index": "wham"
  }
}'

我目前正在使用最后一个卷发,http://127.0.0.1:9200 / _river / wham / _status给了我这个:

{
  "_index": "_river","_type": "wham","_id": "_status","_version": 4,"found": true,"_source": {
    "node": {
      "id": "v1DmcSEOSbKfEbjRdwLYOg","name": "Miles Warren","transport_address": "inet[/192.168.43.211:9300]"
    }
  }
}

所以河流在那里,但我没有看到任何查询到达我的postgresql数据库引擎.我相应地设置了:

su - postgres
initdb --locale en_US.UTF-8 -E UTF8 -D '/tmp/testdb'
postgres -D /tmp/testdb
createdb testdb
psql -d testdb

CREATE TABLE testtable (
    source      varchar(20) NOT NULL,destination varchar(20) NOT NULL,service     int,NOT NULL
);

INSERT INTO testtable VALUES('192.168.0.10','192.168.0.1',80)
INSERT INTO testtable VALUES('192.168.0.11','192.168.0.2',21)

我可以在默认端口查询数据库,它使用用户名和密码运行正常.
我哪里出错了?我是否误解了elasticsearch或者我不应该做/ wham / _search并从提到的SQL查询中获取所有结果?

解决方法

我认为你对查询感到困惑

查询1)

curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
        "type" : "jdbc","jdbc" : {
            "url" : "jdbc:postgresql://localhost:5432/testdb","user" : "postgres","password" : "passywordu","index" : "source","type" : "wham","sql" : "select * from testtable;"
        }
   }'

同时使用上面的查询

您创建名为“source”的索引.因为你创建了一个索引类型的wham.
所以在执行上面的卷曲之后.您需要使用以下格式查询数据

http://127.0.0.1:9200/source/wham/_search

它意味着在索引“source”中搜索数据并输入“wham”.

查询2)

curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
"type" : "jdbc","jdbc" : {
    "strategy" : "simple","poll" : "5s","scale" : 0,"autocommit" : false,"fetchsize" : 10,"max_rows" : 0,"max_retries" : 3,"max_retries_wait" : "10s","url" : "jdbc:postgresql://localhost:5432/testdb","sql" : "select * from testtable","type": "typename",//add the type of documents to be indexed[like tables in RDBMS]
    "index" : "wham"
}
      }'

同时使用上面的查询

你创建一个名为“wham”的索引.因为你创建了一个索引类型的wham.
所以在执行上面的卷曲之后.您需要使用以下格式查询数据

http://127.0.0.1:9200/wham/typename/_search [or]   
    http://127.0.0.1:9200/wham/_search

它意味着在索引“wham”和indextype“typename”中搜索数据.

在尝试上面之前curl.delete _river索引并尝试.如果数据不重要清除数据文件夹并尝试..!

希望能帮助到你..!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读