• 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
    
  • 相关阅读:
    到底什么时候才需要在ObjC的Block中使用weakSelf/strongSelf
    陀螺仪、加速计和磁力计
    UIImage加载图片的方式以及Images.xcassets对于加载方法的影响
    Java-Jdbc
    3.1 基本数据类型
    第三章 数据类型和变量
    2.2.4 给java应用打包
    2.2.3 运行java程序
    2.2.2 编译java源文件
    2.2.1 jdk简介
  • 原文地址:https://www.cnblogs.com/wangbiaohistory/p/16484621.html
Copyright © 2020-2023  润新知