zoukankan      html  css  js  c++  java
  • ElasticSearch常用请求笔记

    新增索引

    PUT - http://localhost:9200/qpyx-search-word?pretty=true
    {
        "settings" : {
            "index" : {
                "number_of_shards" : 3, 
                "number_of_replicas" : 2 
            }
        },  
        "mappings" : {
                "dynamic": false,
                "properties" : {
                    "ip":{
                        "type" : "text"
                    },  
                    "search_word":{
                        "type":"text",
                        "analyzer": "whitespace",
                       "search_analyzer": "whitespace",
                        "fielddata": true #可根据   
                    },  
                    "create_time":{
                        "type":"date",
                        "format":"yyyy-MM-dd HH:mm:ss.SSS"
                    }
                }
        }
    }

    删除索引

    DELETE - http://localhost:9200/qpyx-search-word?pretty=true

    编辑索引

    PUT - localhost:9200/qpyx-search-word/_mapping
    {
      "properties": {
        "search_word": { 
          "type":     "text",
          "analyzer": "whitespace",
          "search_analyzer": "whitespace",
          "fielddata": true
        }
      }
    }

    查询信息

    普通查询

    GET - localhost:9200/qpyx-search-word/_search
    {
         "query": {
              "range": {
                  "create_time": {
                    "gte": "now-3d/d"
                  }
            }
         },
         "sort": [
              {
                   "create_time": {
                        "order": "desc"
                   }
              }
         ]
    }

    根据字段数量展示(热搜)

    GET - localhost:9200/qpyx-search-word/_search
    {
        "size": 0,
        "from": 0,
        "query": {
            "range": {
                  "create_time": {
                    "gte": "now-3d/d"
                  }
            }
        },
        "aggs": {
            "group-msg": {
                "terms": {
                    "field" : "search_word",
                    "size" : 5
                }
            }
        }
    }
  • 相关阅读:
    BZOJ 3677 连珠线
    BZOJ 3676 回文串
    BZOJ 3675 序列分割
    BZOJ 4013 实验比较
    BZOJ 4011 落忆枫音
    使用Google BBR加速 VPS
    OSX编译安装Python3及虚拟开发环境Virtualenv
    OSX安装Mysql8.0
    OpenSSL编程之摘要
    OpenCA搭建
  • 原文地址:https://www.cnblogs.com/zhaww/p/13901722.html
Copyright © 2011-2022 走看看