.net core elk(二) kibana

索引 名称都是小写

//删除索引

DELETE /news  

创建索引 news

PUT /news
{
  "mappings": {
    "properties": {
      "name":{
        "type": "keyword"
         , "analyzer": "standard"
      },
      "address":{
        "type": "text"
      },
      "age":{
        "type": "integer"
      }
    }
  }
}

添加 索引内容

POST /news/_doc
{
  "name":"刘备",
  "address":"蜀国",
  "age":20
}

查询

GET /news/_doc/_search
{
  "query":{
    "match":{
     "address":"魏国"
    }
  }
}

修改索引 _reindex

需求 一个 person 索引 里面已经有索引数据的, 要加一个字段 des 此时该如何操作 

以下是 索引结构

PUT /person
{
  "mappings": {
    "properties": {
      "name":{
        "type": "text"
      },
      "age":{
        "type": "integer"
      },
      "address":{
        "type": "text"
      }
    }
  }
}

先 创建一个persontemplate 索引

PUT /persontemplate
{
  "mappings": {
    "properties": {
      "des": {
        "type": "text"
      },
      "name": {
        "type": "text"
      },
      "age": {
        "type": "integer"
      },
      "address": {
        "type": "text"
      }
    }
  }
}

 

接下来 使用  _reindex

POST _reindex
{
  //
  "source": {
    "index": "person"
  },
  //目标 将 person 索引和内容 迁移到 persontemplate 索引中
  "dest": {
    "index": "persontemplate"
  }
}

查看 字段 是否 添加到索引中

GET /person/_search

 

 现在 数据已经 全部 到  persontemplate 索引中去了 接下来 来个反向操作 把  persontemplate 索引数据迁移到  person中

POST _reindex
{

  "source": {
    "index": "persontemplate"
  },

  "dest": {
    "index": "person"
  }
}

 

这样 就可以把  persontemplate 索引删除   person 中数据就有了

 分页查询

GET /person/_search
{
  "query": {
    "match": {
      "name": ""
    }
  },
  "from": 1,
  "size": 2  
}

 

Elastic Search学习笔记-ES核心概念 - 知乎 (zhihu.com)

【ES知识】ES基础查询语法一览 - 知乎 (zhihu.com)

 

posted on 2023-06-14 17:23  是水饺不是水饺  阅读(47)  评论(0)    收藏  举报

导航