gpt4 book ai didi

elasticsearch - 无法在 Elasticsearch 中创建映射和添加数据

转载 作者:行者123 更新时间:2023-12-04 05:36:19 26 4
gpt4 key购买 nike

每次我按照有关在 elasticsearch 中创建索引、映射和添加数据的说明进行操作时,都会出现错误。
我正在使用 postman 。
首先,我创建索引:

POST http://localhost:9200/schools

(实际上,我必须使用 put 才能成功创建)

接下来,我创建映射并添加数据:
POST http://localhost:9200/schools/_bulk

请求正文
    {
"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"
}
{
"index":{"_index":"schools", "_type":"school", "_id":"3"}
}
{
"name":"Crescent School", "description":"State Board Affiliation", "street":"Tonk Road",
"city":"Jaipur", "state":"RJ", "zip":"176114","location":[26.8535922, 75.7923988],
"fees":2500, "tags":["Well equipped labs"], "rating":"4.5"
}

但我收到的只是:
   {
"error": {
"root_cause": [
{
"type": "json_e_o_f_exception",
"reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@681c6189; line: 1, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@681c6189; line: 2, column: 3]"
}
],
"type": "json_e_o_f_exception",
"reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@681c6189; line: 1, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@681c6189; line: 2, column: 3]"
},
"status": 500
}

最佳答案

这是因为您的请求正文 JSON 格式错误。我建议只检查一个条目,直到您可以将其输入 Elasticsearch,然后添加其他条目。

以下 JSON 是有效的,但我不确定它是否提供了您想要的结构:

{
"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"
}

您可以使用用于格式化和验证 JSON 的工具来确保它是有效的 JSON。下面是一些例子。

http://jsonformatter.org/

https://jsonformatter.curiousconcept.com/

关于elasticsearch - 无法在 Elasticsearch 中创建映射和添加数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42573890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com