要在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中。