Everytime I follow the instruction about Create Index, Mapping and Add Data in elasticsearch i have the error. I'm using Postman. First of all, i create index:
POST http://localhost:9200/schools
(actually, i have to use put to create succesfully)
Next, i create Mapping and Add Data:
POST http://localhost:9200/schools/_bulk
Request Body
{
"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"
}
But all i receive is just:
{
"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
}
You enable dynamic mapping by setting the dynamic parameter to true or runtime . You can then use dynamic templates to define custom mappings that can be applied to dynamically added fields based on the matching condition: match_mapping_type operates on the data type that Elasticsearch detects.
It is not possible to update the mapping of an existing field. If the mapping is set to the wrong type, re-creating the index with updated mapping and re-indexing is the only option available. In version 7.0, Elasticsearch has deprecated the document type and the default document type is set to _doc.
The steps are as follows: Install Logstash via your package manager or by downloading and unzipping the tgz/zip file. Install the Logstash rss input plugin, which allows for reading RSS data sources: ./bin/logstash-plugin install logstash-input-rss.
This is because your request body JSON is malformed. I'd advise checking with just one entry until you can get it into Elasticsearch, then add the others.
The following JSON is valid, though I'm not sure if it provides the structure you want:
{
"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"
}
You can use a tool for formatting and validating JSON to make sure it is valid JSON. Below are some examples.
http://jsonformatter.org/
https://jsonformatter.curiousconcept.com/
I see something which similar to my problem. My problem solved!
Elasticsearch Bulk API - Unexpected end-of-input: expected close marker for ARRAY
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With