• elasticsearch官方文档摸索


    index

    创建索引

    PUT google
    

    映射mapping(注意 mapping不能修改)

    include_type_name,请求体中是否包含type,高版本中会移除type
    Elasticsearc 6.x以后不再支持mapping下多个type,并且 6.x 版本type默认都是 _doc,7.0以后版本将会删除type

    PUT /{index} 有type (deprecated)

    PUT google/user/_mapping?include_type_name=true
    {
      "user": {
        "properties": {
          "name": {
            "type": "text"
          },
          "user_name": {
            "type": "keyword"
          },
          "email": {
            "type": "keyword"
          }
        }
      }
    }
    

    PUT /{index} 没type,默认type为_doc

    PUT google/_mapping
    {
      "properties": {
        "name": {
          "type": "text"
        },
        "user_name": {
          "type": "keyword"
        },
        "email": {
          "type": "keyword"
        }
      }
    }
    

    创建索引+映射mapping

    PUT /{index} 有type (deprecated)

    PUT twitter?include_type_name=true
    {
      "mappings": {
        "user": {
          "properties": {
            "name": {
              "type": "text"
            },
            "user_name": {
              "type": "keyword"
            },
            "email": {
              "type": "keyword"
            }
          }
        }
      }
    }
    

    PUT /{index} 没type,默认type为_doc

    PUT weibo
    {
      "mappings": {
        "properties": {
          "name": {
            "type": "text"
          },
          "user_name": {
            "type": "keyword"
          },
          "email": {
            "type": "keyword"
          }
        }
      }
    }
    

    删除索引

    DELETE google
    

    Document

    创建文档

    PUT /{index}/{type}/{id} (deprecated)

    PUT twitter/user/kimchy
    {
      "name": "Shay Banon",
      "user_name": "kimchy",
      "email": "shay@kimchy.com"
    }
    

    PUT /{index}/_doc/{id}

    PUT twitter/_doc/sharry
    {
      "name": "Shay sharry",
      "user_name": "sharry",
      "email": "shay@sharry.com"
    }
    

    修改文档

    POST /{index}/_update/{id}

    POST twitter/_update/sharry
    {
      "doc": {
        "name": "Shay sharry3"
      }
    }
    

    删除文档

    DELETE /{index}/{type}/{id} (deprecated)

    DELETE /twitter/user/kimchy
    

    DELETE /{index}/_doc/{id}

    DELETE /twitter/_doc/sharry
    

    查询文档

    根据id查询

    GET /{index}/{type}/{id} (deprecated)

    GET /twitter/user/kimchy
    

    GET /{index}/_doc/{id}

    GET /twitter/_doc/sharry
    

    根据queryString查询

    POST /{index}/{type}/_search (deprecated)

    POST /twitter/user/_search
    {
      "query": {
        "query_string": {
          "default_field": "user_name",
          "query": "sharry1"
        }
      }
    }
    

    POST /{index}/_search

    POST /twitter/_search
    {
      "query": {
        "query_string": {
          "default_field": "user_name",
          "query": "sharry1"
        }
      }
    }
    

    根据term查询

    POST /{index}/{type}/_search (deprecated)

    POST /twitter/user/_search
    {
      "query": {
        "term": {
          "query": "sharry1"
        }
      }
    }
    

    POST /{index}/_search

    POST /twitter/_search
    {
      "query": {
        "term": {
          "query": "sharry1"
        }
      }
    }
    

    分词器

  • 相关阅读:
    layui分页获取数据,回显checkbox
    批量选中 及下载
    Module Federation原理剖析
    EMP-面向未来微前端方案正式开源了!
    Vue3 也能用上 Vue2 组件 From EMP
    对比多种微前端方案
    EMP微前端之教你如何搭建共享站
    EMP微前端实战之cocos2d线上项目
    微前端是什么,可以带来什么收益
    Elasticsearch操作实践手册|建议收藏篇
  • 原文地址:https://www.cnblogs.com/jarjune/p/14153567.html
Copyright © 2020-2023  润新知