• es范围查询


    1.看数据 

    POST nba/_search
    {
    	"query": {
    		"ids": {
    			"values": [1, 2]
    		}
    	}
    }
    

      

    {
      "took" : 5,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 2,
          "relation" : "eq"
        },
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "nba",
            "_type" : "_doc",
            "_id" : "1",
            "_score" : 1.0,
            "_source" : {
              "countryEn" : "United States",
              "teamName" : "老鹰",
              "birthDay" : 831182400000,
              "country" : "美国",
              "teamCityEn" : "Atlanta",
              "code" : "jaylen_adams",
              "displayAffiliation" : "United States",
              "displayName" : "杰伦 亚当斯",
              "schoolType" : "College",
              "teamConference" : "东部",
              "teamConferenceEn" : "Eastern",
              "weight" : "86.2 公斤",
              "teamCity" : "亚特兰大",
              "playYear" : 1,
              "jerseyNo" : "10",
              "teamNameEn" : "Hawks",
              "draft" : 2018,
              "displayNameEn" : "Jaylen Adams",
              "heightValue" : 1.88,
              "birthDayStr" : "1996-05-04",
              "position" : "后卫",
              "age" : 23,
              "playerId" : "1629121"
            }
          },
          {
            "_index" : "nba",
            "_type" : "_doc",
            "_id" : "2",
            "_score" : 1.0,
            "_source" : {
              "countryEn" : "New Zealand",
              "teamName" : "雷霆",
              "birthDay" : 743140800000,
              "country" : "新西兰",
              "teamCityEn" : "Oklahoma City",
              "code" : "steven_adams",
              "displayAffiliation" : "Pittsburgh/New Zealand",
              "displayName" : "斯蒂文 亚当斯",
              "schoolType" : "College",
              "teamConference" : "西部",
              "teamConferenceEn" : "Western",
              "weight" : "120.2 公斤",
              "teamCity" : "俄克拉荷马城",
              "playYear" : 6,
              "jerseyNo" : "12",
              "teamNameEn" : "Thunder",
              "draft" : 2013,
              "displayNameEn" : "Steven Adams",
              "heightValue" : 2.13,
              "birthDayStr" : "1993-07-20",
              "position" : "中锋",
              "age" : 26,
              "playerId" : "203500"
            }
          }
        ]
      }
    }
    

      

    2.查找在nba打了2年到10年以内的球员

      这个字段是Long类型

    POST /nba/_search
    {
      "query": {
        "range": {
          "playYear": {
            "gte": 2,
            "lte": 10
          }
        }
      }
    }
    

      

    3.查找1980年到1999年出⽣的球员

      时间的范围查询,date类型,是时间戳

    POST /nba/_search
    {
      "query": {
        "range": {
          "birthDay": {
            "gte": "1999-01-01",
            "lte": "1999-01-09",
            "format": "yyyy-MM-dd"
          }
        }
      }
    }
    

      效果:

    {
      "took" : 1,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 2,
          "relation" : "eq"
        },
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "nba",
            "_type" : "_doc",
            "_id" : "64",
            "_score" : 1.0,
            "_source" : {
              "countryEn" : "Lithuania",
              "teamName" : "尼克斯",
              "birthDay" : 915771600000,
              "country" : "立陶宛",
              "teamCityEn" : "New York",
              "code" : "ignas_brazdeikis",
              "displayAffiliation" : "University of Michigan/Lithuania",
              "displayName" : "伊格纳斯 布拉兹代基斯",
              "schoolType" : "College",
              "teamConference" : "东部",
              "teamConferenceEn" : "Eastern",
              "weight" : "100.2 公斤",
              "teamCity" : "纽约",
              "playYear" : 0,
              "jerseyNo" : "17",
              "teamNameEn" : "Knicks",
              "draft" : 2019,
              "displayNameEn" : "Ignas Brazdeikis",
              "heightValue" : 2.01,
              "birthDayStr" : "1999-01-08",
              "position" : "前锋",
              "age" : 20,
              "playerId" : "1629649"
            }
          },
          {
            "_index" : "nba",
            "_type" : "_doc",
            "_id" : "476",
            "_score" : 1.0,
            "_source" : {
              "countryEn" : "United States",
              "teamName" : "骑士",
              "birthDay" : 915426000000,
              "country" : "美国",
              "teamCityEn" : "Cleveland",
              "code" : "collin_sexton",
              "displayAffiliation" : "University of Alabama/United States",
              "displayName" : "科林 塞克斯顿",
              "schoolType" : "College",
              "teamConference" : "东部",
              "teamConferenceEn" : "Eastern",
              "weight" : "86.2 公斤",
              "teamCity" : "克利夫兰",
              "playYear" : 1,
              "jerseyNo" : "2",
              "teamNameEn" : "Cavaliers",
              "draft" : 2018,
              "displayNameEn" : "Collin Sexton",
              "heightValue" : 1.88,
              "birthDayStr" : "1999-01-04",
              "position" : "后卫",
              "age" : 20,
              "playerId" : "1629012"
            }
          }
        ]
      }
    }
    

      

  • 相关阅读:
    laravel框架——保存用户登陆信息(session)
    laravel框架——增删改查
    laravel框架——表单验证
    laravel框架——上传、下载文件
    Forms & HTML 组件
    phantomJS+Python 隐形浏览器
    Python idle中lxml 解析HTML时中文乱码解决
    python 根据字符串语句进行操作再造函数(evec和eval方法)
    python通过LXML库读取xml命名空间
    Python通过lxml库遍历xml通过xpath查询(标签,属性名称,属性值,标签对属性)
  • 原文地址:https://www.cnblogs.com/juncaoit/p/12716986.html
Copyright © 2020-2023  润新知