如何检索elasticsearch中的所有文档

时间:2017-10-16 05:54:18

标签: json

我是ES的新手,需要帮助。

这是我的JSON数据集

{
    "simplewiki": {
        "page": [{
                "index": {
                    "_index": "myindex",
                    "_type": "wiki",
                    "_id": "1"
                }
            },
            {
                "title": "April",
                "url": "https://simple.wikipedia.org/wiki/April",
                "abstract": "April is the 4th month of the year, and comes between March and May. It is one of four months to have 30 days.",
                "sections": ["The Month", "April in poetry", "Events in April", "Fixed Events", "Moveable Events", "Selection of Historical Events", "Trivia", "References"]
            },

            {
                "index": {
                    "_index": "myindex",
                    "_type": "wiki",
                    "_id": "2"
                }
            },
            {
                "title": "August",
                "url": "https://simple.wikipedia.org/wiki/August",
                "abstract": "August (Aug.) is the 8th month of the year in the Gregorian calendar, coming between July and September.",
                "sections": ["The Month", "August observances", "Fixed observances and events", "Moveable and Monthlong events", "Selection of Historical Events", "Trivia", "References"]
            }
        ]
    }
}

问题是我用下面的命令来索引: curl -XPOST locahost:9200 / myindex / wiki --data-binary @wiki.json

执行后:(52)从服务器清空回复,共2次成功1,失败0。 当我使用命令:curl -XGET localhost:92200 / myindex / wiki / 1?pretty?

我得到以下但不是所有细节,发现是错误的。

{
  "_index":"myindex",
  "_type":"wiki",
  "_id":"1",
  "found" :false
}

如何确保found为true,并检索整个标题和摘要。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

您可以在发布数据后附上收到的消息吗? (我现在无法添加评论)

您可以阅读this然后重试。