elasticsearch常用命令
curl  http//:127.0.0.1:9200/_cat/indices?v 所有索引
curl  http//:127.0.0.1:9200/health?pretty 健康状态
curl  http//:127.0.0.1:9200/product/_doc1 查看某个索引
curl  http//:127.0.0.1:9200/product/mappings 查看映射关系
cutl put http//:127.0.0.1:9200/product/_doc/1 给product建立一个1索引的文档信息
{
  "name":"芋头",
  "da":"2020-10-10 10:10:10",
  "price":66,
  "jiage":66.6
}
POST http//:127.0.0.1:9200/product/_update/1 更新索引的一个字段
{
  "doc":{
    "price":9999  //price一定是上面创建时存在的字段,不然就相当于给索引加了一个新字段
  }
}
cutl POST http//:127.0.0.1:9200/product/open 打开索引
cutl POST http//:127.0.0.1:9200/product/close 关闭索引
cutl http//:127.0.0.1:9200/product/_search查看索引product下的文档数据
cutl http//:127.0.0.1:9200/_cluster/health 集群健康状态
修改索引字段类型
查看原来的映射关系
GET /wangb/_mapping
{
  "wangb" : {
    "mappings" : {
      "properties" : {
        "da" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "jiage" : {
          "type" : "float"
        },
        "name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "price" : {
          "type" : "long"
        }
      }
    }
  }
}
我想把我想把price改成float
PUT wbbb
{
    "mappings": {
        "properties": {
            "da": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "jiage": {
                "type": "float"
            },
            "name": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "price": {
                "type": "float"
            }
        }
    }
}
然后再执行如下命令
POST _reindex
{
  "source": {
    "index": "wangb"
  },
  "dest": {
    "index": "wbbb"
  }
}
删除原来的索引
DELETE /wangb
查看新的映射关系
GET /wbbb/_mapping
本文来自博客园,作者:余生请多指教ANT,转载请注明原文链接:https://www.cnblogs.com/wangbiaohistory/p/16484621.html
 
                    
                
 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号