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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM