• es常用查询学习记录


    DELETE /test

    PUT /test
    {
    "settings": {
    "number_of_shards": 10,
    "number_of_replicas": 1
    }
    }

    DELETE /employee
    ##非结构化新建索引

    PUT /employee
    {
    "settings": {
    "number_of_replicas": 1
    , "number_of_shards": 1
    }
    }


    PUT /employee/_doc/1
    {
    "name":"凯杰2",
    "age":30
    }


    PUT /employee/_doc/1
    {
    "name":"凯杰3"
    }

    ##获取索引记录
    GET /employee/_doc/1

    #指定字段修改
    POST /employee/_update/1
    {
    "doc": {
    "name":"凯杰4"
    }
    }

    #强制指定创建,若已经存在则失败
    POST /employee/_create/6
    {
    "name":"兄长2",
    "age":"31"
    }

    #删除某个文档
    DELETE /employee/_doc/2

    #查询全部文档
    GET /employee/_search

    #使用结构化的方式创建索引
    PUT /employee
    {
    "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1
    },
    "mappings": {
    "properties": {
    "name":{"type":"text"},
    "age":{"type": "integer"}
    }
    }
    }

    #不带条件查询所有记录的方法
    GET /employee/_search
    {
    "query": {
    "match_all": {}
    }
    }

    #分页查询
    GET /employee/_search
    {
    "query": {
    "match_all": {}
    }
    , "from": 0,
    "size": 2
    }

    #带关键字条件查询
    GET /employee/_search
    {
    "query":{
    "match": {
    "name": "兄"
    }
    }
    }

    #带排序
    GET /employee/_search
    {
    "query":{
    "match": {
    "name": "兄"
    }
    }, "sort":[
    {"age":{"order":"asc"}}
    ]
    }

    #带filter term完全匹配 match 分词匹配
    GET /employee/_search
    {
    "query": {
    "bool": {
    "filter": [
    {"term":{"name":"兄111"}}
    ]
    }
    }
    }

    #带聚合
    GET /employee/_search
    {
    "query": {
    "match": {
    "name": "兄"
    }
    },"sort": [
    {
    "age": {
    "order": "desc"
    }
    }
    ],
    "aggs": {
    "group_by_age": {
    "terms": {
    "field": "age"
    }
    }
    }
    }

    #新建一个索引
    PUT /movie/_doc/1
    {
    "name":"Eating an apple a day & keeps the doctor away"
    }

    GET /movie/_search
    {
    "query": {
    "match": {
    "name": "appl"
    }
    }
    }

    #使用analyze api查看分词状态 过滤两次(1.量词,特殊字符 2.词干 英文会大写变小写方便查询)
    GET /movie/_analyze
    {
    "field": "name",
    "text":"Eating an apple a day & keeps the doctor away"
    }

    DELETE /movie

    #使用结构化方式创建索引

    PUT /movie
    {
    "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1
    },
    "mappings": {
    "properties": {
    "name":{"type": "text","analyzer": "english"}
    }
    }
    }

    GET /movie/_search

    #Text 被分析索引的字符串类型
    #keyword不能被分析只能被精确匹配的字符串类型
    #Date日期类型,可以配合format一起使用
    #数字类型 long interger short double
    #boolean true false
    #Array one two
    #Object json嵌套
    #IP 类型
    #Geo_point地址位置

  • 相关阅读:
    vs2013运行qt.exe文件提示错误“找不到Qt5Cored.dll”
    基于stm32f1的lora开发基础通信实验
    vs出现找不到dll,重新安装程序可能会解决此问题
    C&C++&opencv文件操作
    出现无法解析的符号xxx(vs2013)
    opencv目标跟踪检测(C)
    vs运行出错:error MSB8020或error LNK1104: 无法打开文件“opencv_calib3d248d.lib/opencv_contribxxxd.lib”
    vs串口读写dll封装C++#(免费源码分享)
    stm32定时器操作配置()
    pwm控制ili9341背光屏幕亮度(stm32f4)
  • 原文地址:https://www.cnblogs.com/yaohaitao/p/12443435.html
Copyright © 2020-2023  润新知