parent
5ac2ddd2be
commit
a2845c86fe
|
@ -25,14 +25,12 @@ apply plugin: 'elasticsearch.docs-test'
|
||||||
* 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/iprange-aggregation.asciidoc',
|
||||||
'reference/aggregations/bucket/missing-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',
|
||||||
'reference/aggregations/bucket/significantterms-aggregation.asciidoc',
|
'reference/aggregations/bucket/significantterms-aggregation.asciidoc',
|
||||||
'reference/aggregations/bucket/terms-aggregation.asciidoc',
|
'reference/aggregations/bucket/terms-aggregation.asciidoc',
|
||||||
'reference/aggregations/matrix/stats-aggregation.asciidoc',
|
'reference/aggregations/matrix/stats-aggregation.asciidoc',
|
||||||
'reference/aggregations/metrics/cardinality-aggregation.asciidoc',
|
|
||||||
'reference/aggregations/metrics/extendedstats-aggregation.asciidoc',
|
'reference/aggregations/metrics/extendedstats-aggregation.asciidoc',
|
||||||
'reference/aggregations/metrics/percentile-aggregation.asciidoc',
|
'reference/aggregations/metrics/percentile-aggregation.asciidoc',
|
||||||
'reference/aggregations/metrics/percentile-rank-aggregation.asciidoc',
|
'reference/aggregations/metrics/percentile-rank-aggregation.asciidoc',
|
||||||
|
|
|
@ -7,6 +7,7 @@ Example:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
POST /sales/_search?size=0
|
||||||
{
|
{
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"products_without_a_price" : {
|
"products_without_a_price" : {
|
||||||
|
@ -15,6 +16,8 @@ Example:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:sales]
|
||||||
|
|
||||||
In the above example, we get the total number of products that do not have a price.
|
In the above example, we get the total number of products that do not have a price.
|
||||||
|
|
||||||
|
@ -24,11 +27,11 @@ Response:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
|
"aggregations" : {
|
||||||
"aggs" : {
|
|
||||||
"products_without_a_price" : {
|
"products_without_a_price" : {
|
||||||
"doc_count" : 10
|
"doc_count" : 00
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
|
|
@ -10,16 +10,34 @@ match a query:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
POST /sales/_search?size=0
|
||||||
{
|
{
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"author_count" : {
|
"type_count" : {
|
||||||
"cardinality" : {
|
"cardinality" : {
|
||||||
"field" : "author"
|
"field" : "type"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:sales]
|
||||||
|
|
||||||
|
Response:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
...
|
||||||
|
"aggregations" : {
|
||||||
|
"type_count" : {
|
||||||
|
"value" : 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
|
||||||
|
|
||||||
==== Precision control
|
==== Precision control
|
||||||
|
|
||||||
|
@ -29,17 +47,20 @@ experimental[The `precision_threshold` option is specific to the current interna
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
POST /sales/_search?size=0
|
||||||
{
|
{
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"author_count" : {
|
"type_count" : {
|
||||||
"cardinality" : {
|
"cardinality" : {
|
||||||
"field" : "author_hash",
|
"field" : "type",
|
||||||
"precision_threshold": 100 <1>
|
"precision_threshold": 100 <1>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:sales]
|
||||||
|
|
||||||
<1> The `precision_threshold` options allows to trade memory for accuracy, and
|
<1> The `precision_threshold` options allows to trade memory for accuracy, and
|
||||||
defines a unique count below which counts are expected to be close to
|
defines a unique count below which counts are expected to be close to
|
||||||
|
@ -159,33 +180,37 @@ however since hashes need to be computed on the fly.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
POST /sales/_search?size=0
|
||||||
{
|
{
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"author_count" : {
|
"type_promoted_count" : {
|
||||||
"cardinality" : {
|
"cardinality" : {
|
||||||
"script": {
|
"script": {
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"inline": "doc['author.first_name'].value + ' ' + doc['author.last_name'].value"
|
"inline": "doc['type'].value + ' ' + doc['promoted'].value"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:sales]
|
||||||
|
|
||||||
This will interpret the `script` parameter as an `inline` script with the `painless` script language and no script parameters. To use a file script use the following syntax:
|
This will interpret the `script` parameter as an `inline` script with the `painless` script language and no script parameters. To use a file script use the following syntax:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
POST /sales/_search?size=0
|
||||||
{
|
{
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"author_count" : {
|
"type_promoted_count" : {
|
||||||
"cardinality" : {
|
"cardinality" : {
|
||||||
"script" : {
|
"script" : {
|
||||||
"file": "my_script",
|
"file": "my_script",
|
||||||
"params": {
|
"params": {
|
||||||
"first_name_field": "author.first_name",
|
"type_field": "type",
|
||||||
"last_name_field": "author.last_name"
|
"promoted_field": "promoted"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,6 +218,8 @@ This will interpret the `script` parameter as an `inline` script with the `painl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[skip:no script]
|
||||||
|
|
||||||
TIP: for indexed scripts replace the `file` parameter with an `id` parameter.
|
TIP: for indexed scripts replace the `file` parameter with an `id` parameter.
|
||||||
|
|
||||||
|
@ -204,6 +231,7 @@ had a value.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
POST /sales/_search?size=0
|
||||||
{
|
{
|
||||||
"aggs" : {
|
"aggs" : {
|
||||||
"tag_cardinality" : {
|
"tag_cardinality" : {
|
||||||
|
@ -215,5 +243,6 @@ had a value.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:sales]
|
||||||
<1> Documents without a value in the `tag` field will fall into the same bucket as documents that have the value `N/A`.
|
<1> Documents without a value in the `tag` field will fall into the same bucket as documents that have the value `N/A`.
|
||||||
|
|
Loading…
Reference in New Issue