ES-URL查询实例解析

1、语法

curl [ -s][ -g][ -X<REST Verb>][ -H 'Content-Type: application/json'] '<Node>:<Port>/<Index>[/Type][/ID]/_search?pretty&q=<search string>'

  注意要用''包起来,否则后面的&会被识别为“后台执行”,即&后面的内容被忽略

  -s 不输出查询的时间那些东西

  -g 做转义用

  <REST Verb>:REST风格的语法谓词,GET/POST/PUT

  <Node>:节点ip,默认使用localhost

  <port>:节点端口号,默认80,ES默认使用9200

  <Index>:索引名,支持通配符,power_json*

  <Type>:索引类型,由于一个index只有一个type,可不输入

  <ID>:操作对象的ID号,可不输入

  q  :前面加&,后跟查询语句

2、常用参数

q---查询字符串

sort---排序执行。可以是fieldName或 fieldName:asc/ 的形式fieldName:desc。fieldName可以是文档中的实际字段,也可以是特殊_score名称,表示基于分数的排序。可以有几个sort参数(顺序很重要)。

from---从命中的索引开始返回。默认为0。

size---要返回的点击次数。默认为10。

_source_include---查询包含某些source字段的文档。

_source_exclude---查询不包含某些source字段的文档。

timeout---搜索超时,将搜索请求限制在指定的时间值内执行,并使用在到期时累积的点击数进行保释。默认为无超时。

default_field---默认为index.query.default_field,即未指定字段前缀时返回所有字段,索引设置为*

default_operator---默认查询运算符,未指定时默认为OR。

analyzer---用于分析查询字符串的分析器名称。

_source---设置为false禁用_source字段检索。

analyze_wildcard---是否应分析通配符和前缀查询,默认为false

status:active---where the status field contains active

        ---(status相当于fieldname,active相当于值----->TESTID:39232032303039,由于=被用在了前面“q=”,所以这里用“:”代替了“=”)

title:(quick OR brown)---where the title field contains quick or brown. If you omit the OR operator the default operator will be used

author:"John Smith"---where the author field contains the exact phrase "john smith"

_exists_:title---where the field title has any non-null value

date:[2012-01-01 TO 2012-12-31]---All days in 2012

count:[10 TO *]---Numbers from 10 upwards

count:>=10---Numbers from 10 upwards

4、详解

4.1、查询节点

heap.percent:堆内存,1/2最大内存-1和31之间取较小的值,高的话就是ES集群负担比较重,解决:关闭一些索引(阈值差不多可以定在80左右)后会释放一部分heap.percent,但不会释放disk.percent

ram.percent:一直挺高,物理内存的使用情况,Lucene会将闲置的内存都占用做cache,如果有应用使用内存时,cache会被释放出来

cpu:一般不会很高,5以下吧,如果有很多query的话会高,如果一直高释放不掉可能查询语句有问题

node.role:【mdi】master  data  i查询接口(可否在节点上查询)

[zhang@node2 ~]$ curl localhost:19200/_cat/nodes?v

ip            heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name

192.168.243.74          50          98  0    0.09    0.08    0.10 di        -      node5

192.168.243.35          39          90  0    0.11    0.19    0.23 mdi      -      node2

192.168.243.11          57          99  1    0.19    0.14    0.14 mdi      *      node1

192.168.243.51          65          95  0    0.07    0.09    0.13 di        -      node4

192.168.243.40          50          95  0    0.05    0.14    0.20 mdi      -      node3

4.2、查询节点健康状态

[zhang@node2 ~]$ curl localhost:19200/_cat/health?v

epoch      timestamp cluster status node.total node.data shards  pri relo init unassign pending_tasks max_task_wait_time active_shards_percent156110433816:05:38zhang green5530741573260000-100.0%

4.3、查询节点

disk.percent显示占用的硬盘空间

[zhang@node2 ~]$ curl'localhost:19200/_cat/allocation?v&s=node'shards disk.indices disk.used disk.avail disk.total disk.percenthost ip node6151.9tb9.2tb8.9tb18.2tb51192.168.243.11192.168.243.11 node1

  6152.3tb8.7tb9.4tb18.2tb47192.168.243.35192.168.243.35 node2

  6142.2tb7.6tb10.5tb18.2tb42192.168.243.40192.168.243.40 node3

  6152.2tb7.5tb10.6tb18.2tb41192.168.243.51192.168.243.51 node4

  6152.1tb7.1tb      11tb18.2tb39192.168.243.74192.168.243.74node5

4.4、查询索引

[zhang@node2 ~]$ curl'localhost:19200/_cat/indices?v&s=index'//查看索引,并以索引名字排序(s=sort)health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

green  open  bin_power_idx-2000.07.10ggf3VQMbRXmhzIunDDQ1Ow2154384024.3gb12.1gb

      close  bin_power_idx-2018.12.29    u4RfroS4QlGT49bFlFRqJg                                                         

green  open  meter_status_idx-2012.10.01y6pqRWC3TmaAT5ZNfXOxSw2133335018.7mb9.3mb

green  open  power_json-7326403-2019.04EZGhuUBUSA28nspkFL_ibQ2159416810031.5gb15.7gb

green  open  power_json-7326406-2019.02hVow4ibaRAS2kQtLXPbCJQ21115093304058.3gb29.1gb

green  open  power_json-7326419-2019.06uZfizhIHS361y9-u5FvgAw2197416042mb20.9mb

[zhang@node2 ~]$ curl'localhost:19200/_cat/indices/power_json*?v&s=index'//只查看power_json索引,并以索引名字排序(s=sort)health status index                        uuid                  pri rep docs.count docs.deleted store.size pri.store.sizegreen  open  power_json-7326403-2019.04EZGhuUBUSA28nspkFL_ibQ2159416810031.5gb15.7gb

green  open  power_json-7326406-2019.02hVow4ibaRAS2kQtLXPbCJQ21115093304058.3gb29.1gb

green  open  power_json-7326419-2019.06uZfizhIHS361y9-u5FvgAw2197416042mb20.9mb

4.5、查询索引的具体记录信息

[zhang@node2 ~]$ curl'localhost:19200/power_json*?pretty'{

  "power_json-7326414-2019.01" : {

    "aliases" : { },

    "mappings" : {

      "_default_" : {

        "dynamic_templates" : [

          {

            "string_fields" : {

              "match":"*",

              "unmatch":"BIN*",

              "match_mapping_type":"string",

              "mapping" : {

                "ignore_above":256,

                "type":"keyword"              }

            }

          },

          {

            "date_fields" : {

              "match":"TIME",

              "mapping" : {

                "type":"date"              }

            }

          },

          {

            "bin_fields" : {

              "match":"BIN*",

              "mapping" : {

                "type":"binary"              }

            }

          }

        ]

      },

      "power_json" : {

        "dynamic_templates" : [

          {

            "string_fields" : {

              "match":"*",

              "unmatch":"BIN*",

              "match_mapping_type":"string",

              "mapping" : {

                "ignore_above":256,

                "type":"keyword"//字符串类型              }

            }

          },

          {

            "date_fields" : {

              "match":"TIME",

              "mapping" : {

                "type":"date"              }

            }

          },

          {

            "bin_fields" : {

              "match":"BIN*",

              "mapping" : {

                "type":"binary"              }

            }

          }

        ],

        "properties" : {

          "CENTRAL" : {

            "type":"long"          },

          "CITY" : {

            "type":"keyword",

            "ignore_above":256          },

          "CT" : {

            "type":"float"          },

          "GLYS" : {

            "type":"float"//浮点型          },

          "HNAME" : {

            "type":"keyword",

            "ignore_above":256          },

          "HOUSE" : {

            "type":"keyword",

            "ignore_above":256          },

          "IB" : {

            "type":"float"          },

          "ID" : {

            "type":"keyword",

            "ignore_above":256          },

          "IMAX" : {

            "type":"float"          },

          "TESTID" : {

            "type":"keyword",

            "ignore_above":256          },

          "MULT" : {

            "type":"float"          },

          "NAME" : {

            "type":"keyword",

            "ignore_above":256          },

          "ORG_NO" : {

            "type":"keyword",

            "ignore_above":256          },

          "O_N_5" : {

            "type":"keyword",

            "ignore_above":256          },

          "PROVINCE" : {

            "type":"keyword",

            "ignore_above":256          },

          "PT" : {

            "type":"float"          },

          "RAP_R" : {

            "type":"float"          },

          "SOLAR" : {

            "type":"long"          },

          "TG_ADDR" : {

            "type":"keyword",

            "ignore_above":256          },

          "TIME" : {

            "type":"date"          },

          "UNIT" : {

            "type":"keyword",

            "ignore_above":256          },

          "VAL" : {

            "type":"float"          },

          "file" : {

            "type":"keyword",

            "ignore_above":256          }

        }

      }

    },

    "settings" : {

      "index" : {

        "refresh_interval":"5s",

        "number_of_shards":"2",

        "provided_name":"power_json-7326414-2019.01",

        "merge" : {

          "scheduler" : {

            "max_thread_count":"1"          }

        },

        "creation_date":"1546841799515",

        "number_of_replicas":"1",

        "uuid":"40WyopBKRji-tfz4gLREHQ",

        "version" : {

          "created":"5060099"        }

      }

    }

  },

  "power_json-7326410-2019.01" : {

    "aliases" : { },

    "mappings" : {

      "_default_" : {

        "dynamic_templates"

........

4.6、查询字段是否存在

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&q=_exists_:MULT'//查MULT是否存在(_exists_){

  "took":13625,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":1024729047326,

    "max_score":1.0,

    "hits" : [

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLLxKIIEhMjPv28Q",

        "_score":1.0,

        "_source" : {

          "TIME":"2018-07-22T16:00:00","VAL":773260.69,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326401_2018_07_23.csv"        }

      },

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLJXKIIEhMjPv0Rd",

        "_score":1.0,

        "_source" : {

          "TIME":"2018-07-28T16:00:00","VAL":12309.11,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326401_2018_07_29.csv"        }

      },

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLLxKIIEhMjPv28R",

        "_score":1.0,

        "_source" : {

          "TIME":"2018-07-22T16:00:00","HNAME":"",

          "CENTRAL":0,"VAL":14145.36,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,"file":"7326401_2018_07_23.csv"        }

      },

.................

    ]

  }

}

4.7、查询指定值的字段是否存在

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&q=TESTID:10000000107326732674' 查指定TESTID是否存在,status:active

{

  "took":3584,//花费时间"timed_out":false,//是否超时"_shards": {//分片的详细信息"total":416,//查询的分片数"successful":416,//查询成功的分片,不代表分片上有我们需要的信息,只是代表对分片查询成功了"skipped":0,

    "failed":0  },

  "hits": {//命中的情况"total":442,//查询到的结果"max_score":15.078416,//打分"hits": [//数组类型,把命中的详细记录及信息都列出来,hits如果不指定size,默认为10个      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWl1vKjnZsBwX43irtmd",

        "_score":15.078416,//分数高的排在前面,"_source": {//记录的信息内容,_source是一个key,顺序是根据表结构来的"TIME":"2019-03-04T16:00:00","PROVINCE":"TEST","HNAME":"",

          "CENTRAL":0,

          "TESTID":"10000000107326732674",

          "VAL":2287.85,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_03_12.csv"        }

      },

...........

    ]

  }

}

4.8、查询并控制返回的记录条数

默认是10,范围为0-10000

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&q=TESTID:10000000107326732674&size=3'//查询3个,即1-3{

  "took":49,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":442,

    "max_score":15.078416,

    "hits" : [

      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWl1vKjnZsBwX43irtmd",

        "_score":15.078416,

        "_source" : {

          "TIME":"2019-03-04T16:00:00","HNAME":"",

          "CENTRAL":0,"VAL":2287.85,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_03_12.csv"        }

      },

      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWl28lV1ZsBwX43ibsg_",

        "_score":15.078416,

        "_source" : {

          "TIME":"2019-03-05T16:00:00","VAL":2289.95,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_03_13.csv"        }

      },

      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWmbEBHSZsBwX43iFQFE",

        "_score":15.078416,

        "_source" : {

          "TIME":"2019-03-12T16:00:00","VAL":2303.92,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_03_20.csv"        }

      }

    ]

  }

}

4.9、查询并指定起始位置

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&q=TESTID:10000000107326732674&from=2&size=3'//from默认为0,从第3个开始查询3个,{

  "took":3435,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":442,

    "max_score":15.078416,

    "hits" : [

      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWmbEBHSZsBwX43iFQFE",

        "_score":15.078416,

        "_source" : {

          "TIME":"2019-03-12T16:00:00","VAL":2303.92,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_03_20.csv"        }

      },

      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWmgl0SLZsBwX43iu1q1",

        "_score":15.078416,

        "_source" : {

          "TIME":"2019-03-13T16:00:00","VAL":2305.81,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_03_21.csv"        }

      },

      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWnjNmBzZsBwX43iwfvd",

        "_score":15.078416,

        "_source" : {

          "TIME":"2019-03-26T16:00:00","VAL":2325.95,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_04_03.csv"        }

      }

    ]

  }

}

4.10、查询并按指定字段排序

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&q=TESTID:10000000107326732674&sort=TIME:desc'//根据TIME排序(sort),desc降序,默认是升序{

  "took":526,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":442,

    "max_score":null,

    "hits" : [

      {

        "_index":"power_json-7326414-2019.06",

        "_type":"power_json",

        "_id":"AWt1FAobp__ZtGsu1rDf",

        "_score":null,

        "_source" : {

          "TIME":"2019-06-12T16:00:00","VAL":2469.8,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_06_20.csv"        },

        "sort" : [

          1560355200000        ]

      },

      {

        "_index":"power_json-7326414-2019.06",

        "_type":"power_json",

        "_id":"AWtvtXvfp__ZtGsu1SUE",

        "_score":null,

        "_source" : {"VAL":2468.26,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_06_19.csv"        },

        "sort" : [

          1560268800000        ]

      },

    ]

  }

}

4.11、模糊查询

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&analyze_wildcard&q=TESTID:10000000107326732674'//模糊查询{

  "took":38,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":442,

    "max_score":15.078416,

    "hits" : [

      {

        "_index":"power_json-7326414-2019.03",

        "_type":"power_json",

        "_id":"AWl1vKjnZsBwX43irtmd",

        "_score":15.078416,

        "_source" : {

          "TIME":"2019-03-04T16:00:00","VAL":2287.85,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326414_2019_03_12.csv"        }

      },

...........

    ]

  }

}

4.12、比较大小查询

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&q=VAL:<200'//对于数值型和浮点型可以用比较来查{

  "took":12636,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":1811138155,

    "max_score":1.0,

    "hits" : [

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLLxKIIEhMjPv280",

        "_score":1.0,

        "_source" : {

          "TIME":"2018-07-22T16:00:00","HNAME":"",

          "CENTRAL":1,"VAL":0.0,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326401_2018_07_23.csv"        }

      },

...........

    ]

  }

}

4.13、查询并不显示具体内容

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&_source=false'//只要total,不要详细内容信息。{

  "took":2933,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":1024729047326,

    "max_score":1.0,

    "hits" : [

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLLxKIIEhMjPv28Q",

        "_score":1.0      },

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLJXKIIEhMjPv0Rd",

        "_score":1.0      },

..............

    ]

  }

}

4.14、包含指定字段

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&_source_includes=TIME,VAL'//包含TIME和VAL字段的{

  "took":2894,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":1024729047326,

    "max_score":1.0,

    "hits" : [

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLLxKIIEhMjPv28Q",

        "_score":1.0,

        "_source" : {

          "VAL":773260.69,

          "TIME":"2018-07-22T16:00:00"        }

      },

      {

        "_index":"power_json-7326401-2018.07",

        "_type":"power_json",

        "_id":"AWfbqLJXKIIEhMjPv0Rd",

        "_score":1.0,

        "_source" : {

          "VAL":12309.11,

          "TIME":"2018-07-28T16:00:00"        }

      },

..............

    ]

  }

}

4.15、组合查询

[zhang@node2 ~]$ curl -g'localhost:19200/power_json*/_search?pretty&q=(SOLAR:1%20AND%20CENTRAL:1)'//组合查询,{

  "took":4078,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":5732636,

    "max_score":2.0,

    "hits" : [

      {

        "_index":"power_json-7326401-2018.12",

        "_type":"power_json",

        "_id":"AWf4wx0mKIIEhMjP8l5Y",

        "_score":2.0,

        "_source" : {

          "TIME":"2018-12-21T16:00:00","VAL":0.0,

          "MULT":800.0,

          "IB":1.5,

          "IMAX":6.0,

          "SOLAR":1,"CT":8.0,

          "PT":100.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326401_2018_12_22.csv"        }

      },

..........

    ]

  }

}

4.16、范围查询

错误示例:

[zhang@node2 ~]$ curl'localhost:19200/power_json*/_search?pretty&q=TIME:[2019-06-19%20TO%202019-06-20]'//范围查询 TOcurl: (3) [globbing] error: bad range specification after pos52 #要加 -g[zhang@node2~]$ curl -g'localhost:19200/power_json*/_search?pretty&q=TIME:[2019-06-19%20TO%202019-06-20]'//index的日期不对,没有日{

  "took":39,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":0,

    "max_score":null,

    "hits" : [ ]

  }

}

[zhang@node2 ~]$ curl'localhost:19200/_cat/indices/power_json*2019.06*'green open power_json-7326403-2019.06Jso0F_IaS5O-jtA5a8Cgjg2121975591012.4gb6.2gb

green open power_json-7326402-2019.06u4awVtFcQQSL3HBwULFIDg2154000760029.8gb14.9gb

green open power_json-7326407-2019.06tv2L2iZ3RVS_jhZHKhbVtg2140077389022.5gb11.2gb

green open power_json-7326416-2019.06eLBfBfH1RnK_3HWSYzo8Nw211689042308.9gb4.4gb

green open power_json-7326404-2019.063N8Yc0fuT8SiygGdjmV_AA2120415087011.2gb5.5gb

green open power_json-7326419-2019.06uZfizhIHS361y9-u5FvgAw2197416042mb20.9mb

green open power_json-7326413-2019.06QgwuyjdoR-qN_CUSU1SOCw2162795546036.1gb18.2gb

green open power_json-7326405-2019.06GpFkpiffTZusRij4kf8lMg21863507704.7gb2.3gb

green open power_json-7326417-2019.06XqoJssMOQz2h2mcnXA5dsA2143434776023.3gb11.6gb

green open power_json-7326410-2019.06M-osUUC2QIO2zTzGRV4JOQ211789943109.7gb4.8gb

green open power_json-7326409-2019.06fuY0AQuxQfKG9upBovKBIA2127089634015.1gb7.5gb

green open power_json-7326414-2019.06Li-MASxIQAOcq4AUDfZuvA212957773262016.3gb8.2gb

green open power_json-7326406-2019.06YlmVgU4rS8WqcTOX49DbFg217326500276020.6gb10.1gb

green open power_json-7326401-2019.06xPJVFHV4Q3Ku5ivblpELnw2128431876015.6gb7.8gb

green open power_json-7326412-2019.06cxhzsJWKTymC2jFPko90NQ21685102003.9gb1.9gb

green open power_json-7326415-2019.062u0BLAeEQcehmrTyfkfI6A2127869666015gb7.5gb

green open power_json-7326408-2019.066z6YBG2PT3KQzRd75hq0cA2139191130020.8gb10.4gb

green open power_json-7326411-2019.069T6Zf2wlRj-d-kMx_YuOSw211532462808.4gb4.2gb

[zhang@node2 ~]$ curl -g'localhost:19200/power_json*/_search?pretty&q=TIME:[2019-05%20TO%202019-06]'{

  "took":1642,

  "timed_out":false,

  "_shards" : {

    "total":416,

    "successful":416,

    "skipped":0,

    "failed":0  },

  "hits" : {

    "total":1386487997,

    "max_score":1.0,

    "hits" : [

      {

        "_index":"power_json-7326401-2019.05",

        "_type":"power_json",

        "_id":"AWrX1wkJiFDOCQ5wd2jl",

        "_score":1.0,

        "_source" : {

          "TIME":"2019-05-04T16:00:00","VAL":19209.93,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326401_2019_05_12.csv"        }

      },

      {

        "_index":"power_json-7326401-2019.05",

        "_type":"power_json",

        "_id":"AWrX1wkJiFDOCQ5wd2jm",

        "_score":1.0,

        "_source" : {

          "TIME":"2019-05-04T16:00:00","HNAME":"",

          "CENTRAL":0,"VAL":6632.25,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326401_2019_05_12.csv"        }

      },

      {

        "_index":"power_json-7326401-2019.05",

        "_type":"power_json",

        "_id":"AWrX1wkJiFDOCQ5wd2jn",

        "_score":1.0,

        "_source" : {

          "TIME":"2019-05-04T16:00:00","HNAME":"",

          "CENTRAL":0,"VAL":19618.12,

          "MULT":1.0,

          "IB":5.0,

          "IMAX":60.0,

          "SOLAR":0,"CT":1.0,

          "PT":1.0,

          "RAP_R":0.0,

          "GLYS":0.0,"file":"7326401_2019_05_12.csv"        }

      },

.............

    ]

  }

}

4.17、关闭和打开索引

[zhang@node2 ~]$ curl-XPOSTlocalhost:19200/power_json-7326411-2019.06/_close

[zhang@node2 ~]$ curl-XPOSTlocalhost:19200/power_json-7326411-2019.06/_open

4.18、删除符合条件的记录

curl -XPOST'localhost:19200/power_json*/_delete_by_query?pretty&q=TESTID:781128

转发自:https://www.cnblogs.com/daynote/p/11076965.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,921评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,635评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,393评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,836评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,833评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,685评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,043评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,694评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,671评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,670评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,779评论 1 332
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,424评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,027评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,984评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,214评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,108评论 2 351
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,517评论 2 343

推荐阅读更多精彩内容

  • es种有两种查询模式,一种是像传递URL参数一样去传递查询语句,被称为简单搜索或查询字符串(query strin...
    会武功的蚊子阅读 539评论 1 3
  • # 一度蜜v3.0协议 --- # 交互协议 [TOC] ## 协议说明 ### 请求参数 下表列出了v3.0版协...
    c5e350bc5b40阅读 640评论 0 0
  • !/usr/bin/env python -- coding: utf-8 -- '''根据某个traceId去调...
    小七奇奇阅读 628评论 0 0
  • 一二三四五六七,我的朋友在这里。 多唻咪哗嗦啦唏,五弦琴曲传天音。
    苍穹大觉者阅读 237评论 0 3
  • 你见过爱情么? 见过,巴厘岛上,爱琴海边。 我说,白头偕老那种。 恩…… 我给你讲个故事: 女孩...
    清风等徐来阅读 316评论 0 0