要在Elasticsearch中添加文档,可以使用以下两种方法:
POST /my_index/_doc
{
"title": "Example Document",
"content": "This is an example document for Elasticsearch"
}
POST /my_index/_doc/_bulk
{ "index" : { "_id" : "1" } }
{ "title": "Document 1", "content": "This is document 1" }
{ "index" : { "_id" : "2" } }
{ "title": "Document 2", "content": "This is document 2" }
以上是两种常用的方法,可以根据具体的需求选择适合的方法来添加文档到Elasticsearch中。