Skip to content

Commit

Permalink
Add search fields parameter to support high-level field retrieval. (#…
Browse files Browse the repository at this point in the history
…60100)

This feature adds a new `fields` parameter to the search request, which
consults both the document `_source` and the mappings to fetch fields in a
consistent way. The PR merges the `field-retrieval` feature branch.

Addresses #49028 and #55363.
  • Loading branch information
jtibshirani authored Jul 27, 2020
1 parent 700c04d commit 8a89d95
Show file tree
Hide file tree
Showing 117 changed files with 3,219 additions and 388 deletions.
17 changes: 11 additions & 6 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,28 @@ Closure setupTwitter = { String name, int count ->
type: date
likes:
type: long
location:
properties:
city:
type: keyword
country:
type: keyword
- do:
bulk:
index: twitter
refresh: true
body: |'''
for (int i = 0; i < count; i++) {
String user, text
String body
if (i == 0) {
user = 'kimchy'
text = 'trying out Elasticsearch'
body = """{"user": "kimchy", "message": "trying out Elasticsearch", "date": "2009-11-15T14:12:12", "likes": 0,
"location": { "city": "Amsterdam", "country": "Netherlands" }}"""
} else {
user = 'test'
text = "some message with the number $i"
body = """{"user": "test", "message": "some message with the number $i", "date": "2009-11-15T14:12:12", "likes": $i}"""
}
buildRestTests.setups[name] += """
{"index":{"_id": "$i"}}
{"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
$body"""
}
}
setupTwitter('twitter', 5)
Expand Down
18 changes: 9 additions & 9 deletions docs/reference/aggregations/misc.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ GET /twitter/_search?typed_keys
"aggregations": {
"top_users": {
"top_hits": {
"size": 1
"size": 1,
"_source": ["user", "likes", "message"]
}
}
}
Expand Down Expand Up @@ -133,17 +134,16 @@ In the response, the aggregations names will be changed to respectively `date_hi
"total": {
"value": 5,
"relation": "eq"
},
},
"max_score": 1.0,
"hits": [
{
"_index": "twitter",
"_id": "0",
"_score": 1.0,
"_source": {
"date": "2009-11-15T14:12:12",
"message": "trying out Elasticsearch",
"user": "kimchy",
"message": "trying out Elasticsearch",
"likes": 0
}
}
Expand All @@ -167,12 +167,12 @@ request. This is the case for Terms, Significant Terms and Percentiles aggregati
also contains information about the type of the targeted field: `lterms` (for a terms aggregation on a Long field),
`sigsterms` (for a significant terms aggregation on a String field), `tdigest_percentiles` (for a percentile
aggregation based on the TDigest algorithm).


[[indexing-aggregation-results]]
== Indexing aggregation results with {transforms}
<<transforms,{transforms-cap}>> enable you to convert existing {es} indices
into summarized indices, which provide opportunities for new insights and
analytics. You can use {transforms} to persistently index your aggregation

<<transforms,{transforms-cap}>> enable you to convert existing {es} indices
into summarized indices, which provide opportunities for new insights and
analytics. You can use {transforms} to persistently index your aggregation
results into entity-centric indices.
6 changes: 5 additions & 1 deletion docs/reference/docs/get.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ The API returns the following result:
"user": "kimchy",
"date": "2009-11-15T14:12:12",
"likes": 0,
"message": "trying out Elasticsearch"
"message": "trying out Elasticsearch",
"location": {
"city": "Amsterdam",
"country": "Netherlands"
}
}
}
--------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/reference/mapping/types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ string:: <<text,`text`>>, <<keyword,`keyword`>> and <<wildcard,`wildcard
<<nested>>:: `nested` for arrays of JSON objects

[discrete]
[[spatial_datatypes]]
=== Spatial data types

<<geo-point>>:: `geo_point` for lat/lon points
Expand Down
10 changes: 4 additions & 6 deletions docs/reference/modules/cross-cluster-search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ GET /cluster_one:twitter/_search
"match": {
"user": "kimchy"
}
}
},
"_source": ["user", "message", "likes"]
}
--------------------------------------------------
// TEST[continued]
Expand Down Expand Up @@ -113,7 +114,6 @@ The API returns the following response:
"_score": 1,
"_source": {
"user": "kimchy",
"date": "2009-11-15T14:12:12",
"message": "trying out Elasticsearch",
"likes": 0
}
Expand Down Expand Up @@ -147,7 +147,8 @@ GET /twitter,cluster_one:twitter,cluster_two:twitter/_search
"match": {
"user": "kimchy"
}
}
},
"_source": ["user", "message", "likes"]
}
--------------------------------------------------
// TEST[continued]
Expand Down Expand Up @@ -184,7 +185,6 @@ The API returns the following response:
"_score": 2,
"_source": {
"user": "kimchy",
"date": "2009-11-15T14:12:12",
"message": "trying out Elasticsearch",
"likes": 0
}
Expand All @@ -195,7 +195,6 @@ The API returns the following response:
"_score": 1,
"_source": {
"user": "kimchy",
"date": "2009-11-15T14:12:12",
"message": "trying out Elasticsearch",
"likes": 0
}
Expand All @@ -206,7 +205,6 @@ The API returns the following response:
"_score": 1,
"_source": {
"user": "kimchy",
"date": "2009-11-15T14:12:12",
"message": "trying out Elasticsearch",
"likes": 0
}
Expand Down
Loading

0 comments on commit 8a89d95

Please sign in to comment.