【ElasticSearch】文档(添加)单个和批量
创建空索引
PUT myindex
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name": {
"type": "keyword",
"ignore_above": 100
},
"age": {
"type": "integer"
}
}
}
}
单个添加
请求
PUT /<target>/_doc/<_id>
POST /<target>/_doc/
PUT /<target>/_create/<_id>
POST /<target>/_create/<_id>
You cannot add new documents to a data stream using the PUT /<target>/_doc/<_id> request format.
To specify a document ID, use the PUT /<target>/_create/<_id> format instead. See Add documents to a data stream.
1、REST API
文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.13/docs-index_.html
PUT myindex/_create/1
{
"name": "张三",
"age": 20
}
PUT myindex/_doc/2
{
"name": "李四",
"age": 25
}
2、Java REST Client
批量添加
1、REST API
2、Java REST Client
分类:
03_ElasticSearch
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2022-11-11 【MySQL】性能问题排查
2022-11-11 【MySQL】性能优化技巧