elasticsearch 5.x 给定时间范围查询数据

curl -XPOST 'localhost:9200/_search?pretty' -d '{
  "size": 100,  # 返回100条样例结果
  "query": {
    "range": {
      "date_idate": {
        "lt": "2018-06-05T00:00:00",    # 最大日期
        "gte": "2018-05-04T00:00:00"    #最小日期
      }
    }
  }}'

结果示例:

{
  "took" : 29,    # 查询总耗时
  "timed_out" : false,
  "_shards" : {
    "total" : 145,    # 总共查询到多少分片
    "successful" : 145,
    "failed" : 0
  },
  "hits" : {
    "total" : 5536,    # 给定时间范围内命中的数据条数
    "max_score" : 1.0,
    "hits" : [    # 结果数据示例
      {
        "_index" : "ik_sl_v1_201607",
        "_type" : "taonei",
        "_id" : "0_200226979717",
        "_score" : 1.0,
        "_source" : {
          "text_title" : "SUGARMAN T恤",
          "kw_province" : null,
          "date_originalPublishedAt" : null,
          "kw_userAttr" : "时尚搭配师",
          "kw_supplier" : "admaster",
          "kw_gender" : "未知",
          "kw_source" : "taobao.com",
          "double_sentimentNeutral" : 0.4345,
          "text_content" : "好在哪里这个来自香港的潮牌,上学的时候已经在穿了,后来和老公的情侣装也会选择,现在有个宝宝又买了亲子装,一家三口走上街头,回头率不要不要的,可爱的大黄鸭,宝宝每次穿都会嘎嘎的学鸭子叫,真心推荐品牌故事Sugarman坚持香港时尚特色,以个性设计、大胆用色、经典印花为流行要素,着重体现潮人风范;sugarman兼有儿童款与成人款,亲子装、情侣装的独到设计,完美再现爱与分享的品牌文化主旋律。",
          "kw_nickName" : "爱搭配小助手",
          "text_channel" : "aiguangjie",
          "date_publishedAt" : "2016-07-17T22:35:00",
          "kw_userUrl" : "https://daren.taobao.com/account_page/daren_home.htm?wh_weex=true&_wx_appbar=true&user_id=42096364&content_id=200226979717&source=aiguangjie",
          "kw_thirdChannel" : null,
          "long_commentCount" : 0,
          "text_thirdChannel" : null,
          "kw_city" : null,
          "double_sentimentNegative" : 0.1085,
          "date_udate" : "2018-06-04T14:33:55",
          "kw_url" : "https://market.m.taobao.com/apps/market/content/index.html?wh_weex=true&data_prefetch=true&contentId=200226979717&source=aiguangjie&wx_navbar_transparent=true&wx_navbar_hidden=false&params=%7B%22csid%22%3A%229e1f87d33f37993f1503ac2c1c4f63cb%22%7D",
          "long_viewCount" : 193822,
          "long_followerCount" : 14961,
          "kw_commonSentiment" : "正面",
          "nested_goods" : [ ],
          "text_skill" : "",
          "date_idate" : "2018-06-04T14:33:55",
          "long_floor" : 0,
          "date_published" : "2018-05-28T16:36:23",
          "double_sentimentPositive" : 0.457,
          "kw_images" : [
            "https://gw3.alicdn.com/tfscom/tuitui/mt/TB11w3eOVXXXXXeXpXXXXXXXXXX-48-18.png",
            "https://gw3.alicdn.com/tfscom/tuitui/mt/TB11w3eOVXXXXXeXpXXXXXXXXXX-48-18.png",
            "https://gw.alicdn.com/tps/TB10SRRQVXXXXb5XVXXXXXXXXXX"
          ],
          "kw_channel" : "aiguangjie",
          "kw_hashCode" : "2a9c6c63e106e499aa07ee5d7bebdcc2",
          "text_channalDescription" : null,
          "kw_projectID" : "0",
          "long_likeCount" : 0,
          "text_originalContent" : null,
          "text_nickName" : "爱搭配小助手",
          "kw_originalUrl" : null,
          "kw_secondChannel" : null,
          "bool_isComment" : false,
          "long_uid" : 42096364,
          "text_secondChannel" : null
        }
      }
    ]
  }
}

 

posted @ 2018-06-04 14:57  穷开心y  阅读(16192)  评论(0编辑  收藏  举报