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

 

posted @   麻将我会  阅读(1740)  评论(0编辑  收藏  举报
编辑推荐:
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示