zoukankan      html  css  js  c++  java
  • 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

    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
    PUT twitter 
    {
      "mappings": {
        "tweet": {
          "properties": {
            "message": {
              "type": "text"
            }
          }
        }
      }
    }
    

     2.给已存在的Index添加文档类型,同时指定Mapping

    PUT twitter/_mapping/user 
    {
      "properties": {
        "name": {
          "type": "text"
        }
      }
    }
    

     3.给已经存在的Mapping添加新的字段Mapping

    PUT twitter/_mapping/tweet 
    {
      "properties": {
        "user_name": {
          "type": "text"
        }
      }
    }
    

     注意:通常来说,已经存在的 字段Mapping 是不能够被修改的。

    Get Mapping API

    获取整个文档的Mapping信息

    GET /twitter/_mapping/tweet
    

     Get Field Mapping API

    获取指定字段的Mapping信息

    GET publications/_mapping/article/field/title
    

     

  • 相关阅读:
    CodeForces-786B Legacy (线段树优化建图,单源最短路)
    CodeForces-528C Data Center Drama
    CodeForces-723E One-Way Reform
    2-SAT入门
    POJ-3683 Priest John's Busiest Day (2-SAT 求任意可行方案)
    转载: 8天学通MongoDB——第一天 基础入门
    C# 非EF注册登录与EF注册登录
    Asp.Net入门(三)
    非EF分页
    sql语句错误大集合
  • 原文地址:https://www.cnblogs.com/LittleFeiHu/p/6663837.html
Copyright © 2011-2022 走看看