json - Elasticsearch 中的奇怪 Json
问题描述
我正在学习 ELK Stack 进行日志分析,而我无法消化的一件事是,每当我们必须填充索引时,我们必须使用的 JSON 格式并不是真正的 JSON。例如:以下来自于 tutorialspoint 网站,为大量人口填充“学校”类型的“学校”索引:-
{ "index":{ "_index":"schools", "_type":"school", "_id":"1" }}
{"name":"Central School", "description":"CBSE Affiliation", "street":"Nagan","city":"paprola", "state":"HP", "zip":"176115", "location"[31.8955385, 76.8380405],"fees":2000, "tags":["Senior Secondary", "beautiful campus"], "rating":"3.5"}
{ "index":{ "_index":"schools", "_type":"school", "_id":"2" }}
{ "name":"Saint Paul School", "description":"ICSE Afiliation", "street":"Dawarka", "city":"Delhi", "state":"Delhi", "zip":"110075","location":[28.5733056, 77.0122136], "fees":5000,"tags":["Good Faculty", "Great Sports"], "rating":"4.5"}
现在我明白空格是这里的分隔符,并且没有在一行中给出一个实体(索引信息或学校信息),它将返回解析错误。但根据我的理解和这个(供参考),我认为我们确实需要一个顶级密钥(下面的学校),上面有一组数据(索引信息和学校信息)的数组([] ) ,可能如下所示:
{"Schools" : [
{
{"index":{ "_index":"schools", "_type":"school", "_id":"1" }},
{"name":"Central School", "description":"CBSE Affiliation", "street":"Nagan","city":"paprola", "state":"HP", "zip":"176115", "location"[31.8955385, 76.8380405],"fees":2000, "tags":["Senior Secondary", "beautiful campus"], "rating":"3.5"}
},
{
{ "index":{ "_index":"schools", "_type":"school", "_id":"2" }},
{ "name":"Saint Paul School", "description":"ICSE Afiliation", "street":"Dawarka", "city":"Delhi", "state":"Delhi", "zip":"110075","location":[28.5733056, 77.0122136], "fees":5000,"tags":["Good Faculty", "Great Sports"], "rating":"4.5"}
}
]}
我还尝试将 POSTMAN 中的有效负载类型从JSON(applicon/json)更改为TEXT,但它返回一个错误,指出需要以前的有效负载。
我显然在这里遗漏了一些东西。如果有人可以推理上述行为,那将非常有帮助。
解决方案
推荐阅读
- c++ - Clang 总是打破多重继承的继承列表
- ios - 如何在 Swift 中使用 Objective-C 中的 Dispatch_after 函数?
- typescript - TinyMCE Yeoman 无法构建
- php - Yii2回调后如何获取用户身份
- python - ValueError(“找到数量不一致的输入变量” ValueError:找到样本数量不一致的输入变量:[10725, 3575]
- c# - 如何将清单从 sha1 更新到 sha256?
- javascript - 如何从 MVC 控制器显示 Chart.js 折线图
- excel - 如何绕过此 Powershell 警告消息?
- python - WinError 123 文件名、目录名或卷标语法不正确(\u202a 符号?)
- reactjs - 使用 cloneElement 在反应上下文中传递道具