【问题标题】:IndexMissingException[[wham] missingIndexMissingException[[wham] 丢失
【发布时间】:2014-04-25 07:22:53
【问题描述】:

浏览至:http://127.0.0.1:9200/wham/_search
给我:

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

我已经根据这些文档进行了所有设置:

最后一个是目前最有帮助的。
可悲的是,我通过 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",
    "user": "postgres",
    "password": "passywordu",
    "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 查询中获取所有结果?

【问题讨论】:

标签: postgresql jdbc elasticsearch kibana


【解决方案1】:

我认为您对查询感到困惑

查询 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 的索引类型。 所以在执行上面 curl 之后。您需要使用以下格式查询数据

    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",
    "user" : "postgres",
    "password" : "passywordu",
    "sql" : "select * from testtable",
    "type": "typename", //add the type of documents to be indexed[like tables in RDBMS]
    "index" : "wham"
}
      }'

在使用上述查询时

您创建了一个名为“wham”的索引。这样,您就可以创建 wham 的索引类型。 所以在执行上面 curl 之后。您需要使用以下格式查询数据

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

表示在索引“wham”和索引类型“typename”中搜索数据。

在尝试上述curl之前。删除_river索引并尝试。如果数据不重要,请清除数据文件夹并尝试..!

希望对您有所帮助..!

【讨论】:

  • 抱歉花了这么长时间才回复你,我花了一段时间才回到环境并测试了这些东西。我确实混淆了格式。你的帮助让我走得很远,所以我感谢你,即使言语无法形容感激! ^^
猜你喜欢
  • 1970-01-01
  • 2015-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-23
  • 1970-01-01
相关资源
最近更新 更多