- 根据条件 更新
- 根据条件删除
- 查询某个条件下的所有条数
- 多个条件下查询字段"RecvBytes"下的count min max avg sum信息
- 查询"RecvBytes"字段的某个区间内的数据(他会统计出来0-100之间的数据,100-200之间的数据,200以上数据)
- 查询"RecvBytes"字段的某个区间内的数据(他会统计出来0-100之间的数据然后还有min max avg count sum,100-200之间的数据的min max avg count sum,200以上数据的min max avg count sum)
- 两个条件查询(其中一个条件是sendbytes的数量大于140)
- 查询"RecvBytes"字段下的值大于175的所有数据
- 查询两个条件下按照"RecvBytes"字段升序排序(只能排序数据和日期)
- 查询"SendStartTime"字段的固定范围内,然后按照升降序排列
- 查询某些条件下, "SendBytes"字段的平均值(avg是平均值,max是最大值,min是最小值,只需改avg为max就ok)最低端会出现一个value值就是平均值、最大值或者最小值
- 创建索引并设置分片数和表结构
1.根据条件 更新
ip 表名 方法名
POST http://192.168.12.161:9200/session-*/_update_by_query body-raw-JSON(application/json)
要修改的东西 根据修改条件一 根据修改条件二
{"script":{"source":"ctx._source['RecvBytes']='2';"},"query":{"bool":{"filter":[{"term":{"Tag.keyword":"/home/csmdp/pcap_input/Testcetc"}},{"term":{"sessionID":"3_1557394853_37421"}}]}}}'
然后send 查看update是否为0 .为 0表示未更新 为1表示更新一条数据
-
根据条件删除
ip 表名 方法名
POST http://192.168.12.161:9200/session-*/_detele_by_query body-raw-JSON(application/json)条件一key 条件一value 条件二key 条件二 value
{"query":{
"bool":{
"filter":[
{"term":{"Tag.keyword":"/home/csmdp/pcap_input/Testcetc"}},
{"term":{"sessionID":"3_1557394853_37421"}}
]
}}}
然后send 查看delete是否为0 . 为 0表示未删除 为1表示删除一条数据
3 查询某个条件下的所有条数
http://192.168.12.12:9200/haha/_count
{
"query" : {
"bool" : {
"filter" : {
"term":{
"TopProtocol":"https"}}
}
}}
4
多个条件下"RecvBytes"字段数量查询(查询senbytes数量)
POST http://192.168.12.161:9200/session-*/_search body-raw-JSON(application/json)
{
"query" : {
"bool" : {
"filter" : [{
"term":{
"Tag.keyword":"/home/csmdp/pcap_input/Testcetc"}},{"term":{"Status.keyword":"Ended"}
}]
}
},
"aggs" : {
"sendBytes" : {
"sum" : {
"field" : "SendBytes"
}
}
}
}
5 多个条件下查询字段"RecvBytes"下的count min max avg sum信息
http://192.168.12.165:9200/session-*/_search
{
"query" : {
"bool" : {
"filter" : [{
"term":{"Tag.keyword":"/home/csmdp/pcap_input/Testcetc"}},{"term":{"Status.keyword":"Ended"}
}]
}
},
"aggs" : {
"sendBytes" : {
"stats" : {
"field" : "RecvBytes"
}
}
}
}
6 查询"RecvBytes"字段的某个区间内的数据(他会统计出来0-100之间的数据,100-200之间的数据,200以上数据)
http://192.168.12.165:9200/session-*/_search
{
"aggs" : {
"price_ranges" : {
"range" : {
"field" : "SendBytes" ,
"ranges" : [
{ "to" : 100.0 },
{ "from" : 100.0, "to" : 200.0 },
{ "from" : 200.0 }
]
}
}
}
}
7 查询"RecvBytes"字段的某个区间内的数据(他会统计出来0-100之间的数据然后还有min max avg count sum,100-200之间的数据的min max avg count sum,200以上数据的min max avg count sum)
http://192.168.12.165:9200/session-*/_search
{
"aggs" : {
"price_ranges" : {
"range" : {
"field" : "SendBytes",
"ranges" : [
{ "to" : 100 },
{ "from" : 100, "to" : 200 },
{ "from" : 200 }
]
},
"aggs" : {
"price_stats" : {
"stats" : { "field" : "SendBytes" }
}
}
}
}
}
8 两个条件查询(其中一个条件是sendbytes的数量大于140)
http://192.168.12.165:9200/session-*/_search
{
"query": {
"bool": {
"filter": [
{ "term": { "Status.keyword": "Ended" }},
{ "range": { "SendBytes": { "gte": "140" }}}
]
}
}
}
或者三个条件查询(其中一个条件是sendbytes的数量大于140)
http://192.168.12.165:9200/session-*/_search
{
"query": {
"bool": {
"filter": [
{ "term": { "Status.keyword": "Ended" }},
{ "term": { "SendBytes": "174" }},
{ "range": { "SendBytes": { "gte": "10" }}}
]
}
}
}
9 查询"RecvBytes"字段下的值大于175的所有数据
http://192.168.12.165:9200/session-*/_search
{
"query": {
"range" : {
"SendBytes" : {
"gte" : 175
}
}
}
}
10 查询两个条件下按照"RecvBytes"字段升序排序(只能排序数据和日期)
{
"query" : {
"bool" : {
"filter" : [{
"term":{
"Tag.keyword":"/home/csmdp/pcap_input/Testcetc"}},{"term":{"Status.keyword":"Ended"}
}]
}
},
"sort" : [
{"SendBytes" : {"order" : "asc", "mode" : "avg"}}
]
}
11 查询"SendStartTime"字段的固定范围内,然后按照升降序排列
asc
{
"query":{
"bool":{
"filter":[{
"range":{
"SendStartTime":{
"from":1557200821855,
"to":1557200823151
}
}}
]
}
},
"sort":[{"SendStartTime":{"order":"desc"}}
]
}
12 查询某些条件下, "SendBytes"字段的平均值(avg是平均值,max是最大值,min是最小值,只需改avg为max就ok)最低端会出现一个value值就是平均值、最大值或者最小值
{
"query" : {
"bool" : {
"filter" : [{
"term":{
"Tag.keyword":"/home/csmdp/pcap_input/Testcetc"}},{"term":{"Status.keyword":"Ended"}
}]
}
},
"aggs" : {
"avg_grade" : { "avg" : { "field" : "SendBytes" } }
}
}
13、
{
"query" : {
"bool" : {
"filter" : [{
"term":{"Tag.keyword":"空"}},
{"term":{"Status.keyword":"Ended"}
}]
}
},
"size":0,
"aggs" : {
"sendBytes" : {
"stats" : {
"field" : "SendBytes"
}
},
"recvBytes" : {
"stats" : {
"field" : "RecvBytes"
}
},
"totalBytes_SUM_G":{
"sum":{
"script":{
"source":"(doc['SendBytes'].value * 1.0 + doc['RecvBytes'].value *1.0 ) / params.div_num ",
"params" : {
"div_num" : 1073741824
}
}
}
},
"totalBytes_SUM_M" : {
"sum":{
"script":{
"source":"(doc['SendBytes'].value * 1.0 + doc['RecvBytes'].value *1.0 ) / params.div_num ",
"params" : {
"div_num" : 1048576
}
}
}
}
}
}
14 PUT 192.168.12.148:19200/indiex
{
"settings" : {
"index" : {
"number_of_shards" : 900, #设置分片数
"number_of_replicas" : 0 #设置备份数
}
},
"mappings" : {
"_doc" : {
"dynamic_templates": [{ #设置其他字段的type为keyword
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}],
"properties" : {
"IPV4" : { "type" : "ip" }, #设置IPV4的type为ip
"IPV6": {"type": "ip"},
"binary": { "type": "binary","index":false} //设置binary不创建索引
}
}
}
}
965

被折叠的 条评论
为什么被折叠?



