// 全部查询
GET student_task_status*/_search
{
"query":{
"match_all": {}
}
}
// 获取数据结构
GET student_task_status*/_mapping
//删除索引
DELETE student_task_status
// 条件查询
GET student_task_status/_search
{
"from":0,
"size": 0,
"query":{
"bool":{
"must":[
{
"exists":{
"field":"taskId",
"boost":1
}
}
],
"filter":[
{
"range":{
"beginTime":{
"from":"2020-04-10T00:00:00:000Z",
"include_lower":true,
"include_upper":true,
"format":"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
"boost":1
}
}
}
],
"adjust_pure_negative":true,
"boost":1
}
},
"version":true,
"aggregations":{
"date":{
"date_histogram":{
"field":"beginTime",
"format":"yyyy-MM-dd",
"interval":"1d",
"offset":0,
"order":{
"_key":"asc"
},
"keyed":false,
"min_doc_count":0
}
}
}
}
// 条件查询,通配符查询
GET self*/_search
{
"query":{
"bool":{
"must": [
{
"fuzzy": {
"tokenCreTimeStr": "-"
}
}
]
}
},
"from":0,
"size":20
}
// 条件查询
GET self*/_search
{
"query":{
"term": {
"tokenCreTimeStr.keyword": "2020-04-17-14:24:381"
}
}
}
// 条件删除
POST self*/_delete_by_query
{
"query": {
"term": {
"tokenCreTimeStr.keyword": "2020年04月17日"
}
}
}
// 全查
GET self-2020.04.17-new/_search
{
"query": {
"match_all": {}
}
}
// 删除
DELETE self-2020.04.17-new
GET self-2020.04.17/_mapping
GET self-2020.04.17-new/_mapping
// 新增索引,设置数据类型
PUT self-2020.04.17-new
{
"mappings": {
"doc": {
"properties": {
"tokenCreTimeStr": {
"type": "date"
}
}
}
}
}
// 拷贝数据
POST _reindex
{
"source": {
"index": "self-2020.04.17"
},
"dest": {
"index": "self-2020.04.17-new"
}
}
DELETE self-2020.04.17
// 设置别名
POST /_aliases
{
"actions": [
{"add": {"index": "self-2020.04.17-new", "alias": "self-2020.04.17"}}
]
}
// 获取别名
GET selflearning-2020.04.17-new/_alias/*
// 删除别名
POST _aliases
{
"actions": [
{
"remove": {
"index": "selflearning-2020.04.17-new",
"alias": "selflearning-2020.04.17"
}
}
]
}
// 查询在线人数,每个人的最后一条记录
GET self-2020.04.17-new/_search
{
"from": 0,
"size": 0,
"query": {
"bool": {
"must": [{
"term": {
"hasLogin": true
}
}],
"filter": [{
"range": {
"@timestamp": {
"from": "2020-05-18T03:10:28.430Z",
"to": null,
"include_lower": true,
"include_upper": true,
"format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
"boost": 1
}
}
}],
"adjust_pure_negative": true,
"boost": 1
}
},
"aggs": {
"data": {
"terms": {
"field": "userId.keyword",
"size": 10000
},
"aggs": {
"top_page": {
"top_hits": {
"size": 1,
"sort": [{
"@timestamp": {
"order": "desc"
}
}],
"_source": {
"includes": ["path", "userId", "realName", "publicIp", "sourceFrom", "roleCodes", "schoolName", "@timestamp"]
}
}
}
}
}
},
"version": true
}