Reputation: 4716
What i need
i need to Insert Test document.
i have followed link https://www.elastic.co/guide/en/elasticsearch/reference/current/_index_and_query_a_document.html
Here im trying
PUT /customer/_doc/1?pretty
{
"name": "John Doe"
}
Error request body is required
snapshot when i try to run url
1.http://localhost:9200/customer?pretty
2.http://localhost:9200/customer/_doc/1?pretty&pretty
3.http://localhost:9200/customer/_doc/1?pretty&pretty&name=test
can anyone suggest how to Insert document in Elastic search.
Upvotes: 7
Views: 26552
Reputation: 8678
Use the PUT method for the same.
The url would be "http://localhost:9200/movies/"
movies is the name of the index.
The json to post is :
{
"id" : 1,
"title" : "Toy Story 1",
"year" : 1995,
"category" : "Adventure"
}
Here is the screenshot of the postman pushing the data to elasticseach :
You can verify the data as below :
Use the GET method and the url as http://localhost:9200/movies/_search?
Upvotes: 3
Reputation: 5135
Pass the Json in body and change the URL as shown below:
Upvotes: 4