• 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
                }
            }
        }
    }
  • 相关阅读:
    javascript中的继承实现
    【414】Code::Blocks增加主题
    【413】C 语言 Command line
    【412】Linux 系统编译 C 程序
    【411】COMP9024 Assignment1 问题汇总
    【410】Linux 系统 makefile 文件
    Solr的入门知识
    Java8新特性
    Linux命令大全
    为博客园博文添加目录的两种方法
  • 原文地址:https://www.cnblogs.com/zhaww/p/13901722.html
Copyright © 2020-2023  润新知