0

我是弹性搜索的新手,我正在尝试在官方网页上遵循一些基本示例。我使用以下映射创建了一个简单的索引:

curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
    "tweet" : {
        "properties" : {
            "message" : {"type" : "string", "index": "not_analyzed" },
            "user" : {"type" : "string", "index": "not_analyzed" }
        }
    }
}'

然后我放了一些这样的数据:

curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
    user: "avoidness",
    message : "hey elasticsearch!"
}'

在 Kibana 中,当我搜索放入索引的数据时,似乎一切正常 - 除了表格面板。即使所有其他面板都正确显示搜索结果,它也始终显示一个空表,其中包含“0 到 0 的 0 可用于分页”。我正在使用 ES v1.0.0 和 Kibana v3.0.0 里程碑 5。

表格面板上还有一个带有 curl 查询的检查框架,所以我尝试从终端运行它,它似乎工作正常,这就是它返回的内容:

{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : null,
    "hits" : [ {
      "_index" : "twitter",
      "_type" : "tweet",
      "_id" : "2",
      "_score" : null, "_source" : {
        user: "avoidness",
        message : "hey hou"
      },
      "sort" : [ "2" ]
    }, {
      "_index" : "twitter",
      "_type" : "tweet",
      "_id" : "1",
      "_score" : null, "_source" : {
        user: "avoidness",
        message : "hey elasticsearch!"
      },
      "sort" : [ "1" ]
    } ]
  }
}

你知道为什么我仍然得到一张空桌子吗?

4

1 回答 1

1

TL;DR:您的输入文档不是有效的 JSON:它错过了键名周围的双引号。修复它,它会工作。

elasticsearch JSON 解析器很灵活,可以解析无效的 JSON,从而生成有效的索引。大多数 kibana 组件只使用索引中的数据,并且可以正常工作。然而,表格组件请求文档源:由于它是逐字存储的,因此表格查询返回的数据被它污染,浏览器拒绝解析生成的无效 JSON。

这个问题也在https://github.com/elasticsearch/kibana/issues/1088#issuecomment-49405144中得到解决。

于 2014-07-21T15:47:07.547 回答