ElasticSearch Index API && Mapping
ElasticSearch NEST Client 操作Index
var indexName="twitter";
var deleteIndexResponse = client.DeleteIndex(indexName);
var createIndexResponse = client.CreateIndex(indexName);
var getIndexResponse = client.GetIndex(indexName);
var indexExistsResponse = client.IndexExists(indexName);
var openIndexResponse=client.OpenIndex(indexName);
var closeIndexResponse=client.CloseIndex(indexName);
1.创建Index
1 2 3 | PUT twitter { } |
2.删除Index
DELETE /twitter
3.获取Index
GET /twitter
4.检查是否存在Index
HEAD twitter
5.打开关闭Index
POST /twitter/_close
POST /twitter/_open
PUT mapping
1.创建Index 同时为字段添加Mapping
1 2 3 4 5 6 7 8 9 10 11 12 | PUT twitter { "mappings" : { "tweet" : { "properties" : { "message" : { "type" : "text" } } } } } |
2.给已存在的Index添加文档类型,同时指定Mapping
1 2 3 4 5 6 7 8 | PUT twitter/_mapping/user { "properties" : { "name" : { "type" : "text" } } } |
3.给已经存在的Mapping添加新的字段Mapping
1 2 3 4 5 6 7 8 | PUT twitter/_mapping/tweet { "properties" : { "user_name" : { "type" : "text" } } } |
注意:通常来说,已经存在的 字段Mapping 是不能够被修改的。
Get Mapping API
获取整个文档的Mapping信息
1 | GET /twitter/_mapping/tweet |
Get Field Mapping API
获取指定字段的Mapping信息
1 | GET publications/_mapping/article/field/title |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步