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"
}
}
]
}
}