parent
e7eda5e1be
commit
829f7cb658
|
@ -24,7 +24,6 @@ apply plugin: 'elasticsearch.docs-test'
|
||||||
* only remove entries from this list. When it is empty we'll remove it
|
* only remove entries from this list. When it is empty we'll remove it
|
||||||
* entirely and have a party! There will be cake and everything.... */
|
* entirely and have a party! There will be cake and everything.... */
|
||||||
buildRestTests.expectedUnconvertedCandidates = [
|
buildRestTests.expectedUnconvertedCandidates = [
|
||||||
'reference/aggregations/bucket/iprange-aggregation.asciidoc',
|
|
||||||
'reference/aggregations/bucket/nested-aggregation.asciidoc',
|
'reference/aggregations/bucket/nested-aggregation.asciidoc',
|
||||||
'reference/aggregations/bucket/range-aggregation.asciidoc',
|
'reference/aggregations/bucket/range-aggregation.asciidoc',
|
||||||
'reference/aggregations/bucket/reverse-nested-aggregation.asciidoc',
|
'reference/aggregations/bucket/reverse-nested-aggregation.asciidoc',
|
||||||
|
@ -505,3 +504,42 @@ for (int i = 0; i < 100; i++) {
|
||||||
{"index":{}}
|
{"index":{}}
|
||||||
{"load_time": "$value"}"""
|
{"load_time": "$value"}"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used by iprange agg
|
||||||
|
buildRestTests.setups['iprange'] = '''
|
||||||
|
- do:
|
||||||
|
indices.create:
|
||||||
|
index: ip_addresses
|
||||||
|
body:
|
||||||
|
settings:
|
||||||
|
number_of_shards: 1
|
||||||
|
number_of_replicas: 1
|
||||||
|
mappings:
|
||||||
|
data:
|
||||||
|
properties:
|
||||||
|
ip:
|
||||||
|
type: ip
|
||||||
|
- do:
|
||||||
|
bulk:
|
||||||
|
index: ip_addresses
|
||||||
|
type: data
|
||||||
|
refresh: true
|
||||||
|
body: |'''
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < 255; i++) {
|
||||||
|
buildRestTests.setups['iprange'] += """
|
||||||
|
{"index":{}}
|
||||||
|
{"ip": "10.0.0.$i"}"""
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
buildRestTests.setups['iprange'] += """
|
||||||
|
{"index":{}}
|
||||||
|
{"ip": "9.0.0.$i"}"""
|
||||||
|
buildRestTests.setups['iprange'] += """
|
||||||
|
{"index":{}}
|
||||||
|
{"ip": "11.0.0.$i"}"""
|
||||||
|
buildRestTests.setups['iprange'] += """
|
||||||
|
{"index":{}}
|
||||||
|
{"ip": "12.0.0.$i"}"""
|
||||||
|
}
|
|
@ -7,7 +7,9 @@ Example:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
GET /ip_addresses/data/_search
|
||||||
{
|
{
|
||||||
|
"size": 10,
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"ip_ranges" : {
|
"ip_ranges" : {
|
||||||
"ip_range" : {
|
"ip_range" : {
|
||||||
|
@ -21,6 +23,8 @@ Example:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:iprange]
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
|
@ -34,23 +38,26 @@ Response:
|
||||||
"buckets" : [
|
"buckets" : [
|
||||||
{
|
{
|
||||||
"to": "10.0.0.5",
|
"to": "10.0.0.5",
|
||||||
"doc_count": 4
|
"doc_count": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"from": "10.0.0.5",
|
"from": "10.0.0.5",
|
||||||
"doc_count": 6
|
"doc_count": 260
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
|
||||||
|
|
||||||
IP ranges can also be defined as CIDR masks:
|
IP ranges can also be defined as CIDR masks:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
GET /ip_addresses/data/_search
|
||||||
{
|
{
|
||||||
|
"size": 0,
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"ip_ranges" : {
|
"ip_ranges" : {
|
||||||
"ip_range" : {
|
"ip_range" : {
|
||||||
|
@ -64,32 +71,37 @@ IP ranges can also be defined as CIDR masks:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:iprange]
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
|
...
|
||||||
|
|
||||||
"aggregations": {
|
"aggregations": {
|
||||||
"ip_ranges": {
|
"ip_ranges": {
|
||||||
"buckets": [
|
"buckets": [
|
||||||
{
|
{
|
||||||
"key": "10.0.0.0/25",
|
"key": "10.0.0.0/25",
|
||||||
"from": "10.0.0.0",
|
"from": "10.0.0.0",
|
||||||
"to": "10.0.0.127",
|
"to": "10.0.0.128",
|
||||||
"doc_count": 127
|
"doc_count": 128
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "10.0.0.127/25",
|
"key": "10.0.0.127/25",
|
||||||
"from": "10.0.0.0",
|
"from": "10.0.0.0",
|
||||||
"to": "10.0.0.127",
|
"to": "10.0.0.128",
|
||||||
"doc_count": 127
|
"doc_count": 128
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
|
||||||
|
|
||||||
==== Keyed Response
|
==== Keyed Response
|
||||||
|
|
||||||
|
@ -97,11 +109,13 @@ Setting the `keyed` flag to `true` will associate a unique string key with each
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
GET /ip_addresses/data/_search
|
||||||
{
|
{
|
||||||
|
"size": 0,
|
||||||
"aggs": {
|
"aggs": {
|
||||||
"ip_ranges": {
|
"ip_ranges": {
|
||||||
"ip_range": {
|
"ip_range": {
|
||||||
"field": "remote_ip",
|
"field": "ip",
|
||||||
"ranges": [
|
"ranges": [
|
||||||
{ "to" : "10.0.0.5" },
|
{ "to" : "10.0.0.5" },
|
||||||
{ "from" : "10.0.0.5" }
|
{ "from" : "10.0.0.5" }
|
||||||
|
@ -112,6 +126,8 @@ Setting the `keyed` flag to `true` will associate a unique string key with each
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:iprange]
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
|
@ -125,27 +141,30 @@ Response:
|
||||||
"buckets": {
|
"buckets": {
|
||||||
"*-10.0.0.5": {
|
"*-10.0.0.5": {
|
||||||
"to": "10.0.0.5",
|
"to": "10.0.0.5",
|
||||||
"doc_count": 1462
|
"doc_count": 10
|
||||||
},
|
},
|
||||||
"10.0.0.5-*": {
|
"10.0.0.5-*": {
|
||||||
"from": "10.0.0.5",
|
"from": "10.0.0.5",
|
||||||
"doc_count": 50000
|
"doc_count": 260
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
|
||||||
|
|
||||||
It is also possible to customize the key for each range:
|
It is also possible to customize the key for each range:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
GET /ip_addresses/data/_search
|
||||||
{
|
{
|
||||||
|
"size": 0,
|
||||||
"aggs": {
|
"aggs": {
|
||||||
"ip_ranges": {
|
"ip_ranges": {
|
||||||
"ip_range": {
|
"ip_range": {
|
||||||
"field": "remote_ip",
|
"field": "ip",
|
||||||
"ranges": [
|
"ranges": [
|
||||||
{ "key": "infinity", "to" : "10.0.0.5" },
|
{ "key": "infinity", "to" : "10.0.0.5" },
|
||||||
{ "key": "and-beyond", "from" : "10.0.0.5" }
|
{ "key": "and-beyond", "from" : "10.0.0.5" }
|
||||||
|
@ -156,6 +175,8 @@ It is also possible to customize the key for each range:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:iprange]
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
|
@ -169,14 +190,15 @@ Response:
|
||||||
"buckets": {
|
"buckets": {
|
||||||
"infinity": {
|
"infinity": {
|
||||||
"to": "10.0.0.5",
|
"to": "10.0.0.5",
|
||||||
"doc_count": 1462
|
"doc_count": 10
|
||||||
},
|
},
|
||||||
"and-beyond": {
|
"and-beyond": {
|
||||||
"from": "10.0.0.5",
|
"from": "10.0.0.5",
|
||||||
"doc_count": 50000
|
"doc_count": 260
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
|
Loading…
Reference in New Issue