[DOCS] Replace `twitter` dataset in docs (#60604) (#60609)

This commit is contained in:
James Rodewig 2020-08-03 13:31:19 -04:00 committed by GitHub
parent fc63f8224f
commit 26d51089da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 151 additions and 117 deletions

View File

@ -184,6 +184,6 @@ The following is an example of getting the cluster health at the
[source,console]
--------------------------------------------------
GET /_cluster/health/twitter?level=shards
GET /_cluster/health/my-index-000001?level=shards
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]

View File

@ -1100,7 +1100,7 @@ Number of selected nodes using the distribution flavor and file type.
--------------------------------------------------
GET /_cluster/stats?human&pretty
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
The API returns the following response:

View File

@ -57,7 +57,7 @@ operation that removes corrupted data from the shard.
[source,txt]
--------------------------------------------------
$ bin/elasticsearch-shard remove-corrupted-data --index twitter --shard-id 0
$ bin/elasticsearch-shard remove-corrupted-data --index my-index-000001 --shard-id 0
WARNING: Elasticsearch MUST be stopped before running this tool.

View File

@ -63,7 +63,7 @@ Example to delete with routing
[source,console]
--------------------------------------------------
PUT /my-index-000001/_doc/1?routing=kimchy
PUT /my-index-000001/_doc/1?routing=shard-1
{
"test": "test"
}
@ -73,7 +73,7 @@ PUT /my-index-000001/_doc/1?routing=kimchy
[source,console]
--------------------------------------------------
DELETE /my-index-000001/_doc/1?routing=kimchy
DELETE /my-index-000001/_doc/1?routing=shard-1
--------------------------------------------------
// TEST[continued]

View File

@ -506,14 +506,14 @@ The following EQL search request searches for events with an `event.category` of
`file` that meet the following conditions:
* A `file.name` of `cmd.exe`
* An `agent.id` other than `my_user`
* An `agent.id` other than `8a4f526c`
[source,console]
----
GET /my-index-00001/_eql/search
{
"query": """
file where (file.name == "cmd.exe" and agent.id != "my_user")
file where (file.name == "cmd.exe" and agent.id != "8a4f526c")
"""
}
----
@ -616,7 +616,7 @@ that:
--
* An `event.category` of `file`
* A `file.name` of `cmd.exe`
* An `agent.id` other than `my_user`
* An `agent.id` other than `8a4f526c`
--
. Followed by an event with:
+
@ -633,7 +633,7 @@ GET /my-index-00001/_eql/search
{
"query": """
sequence by agent.id
[ file where file.name == "cmd.exe" and agent.id != "my_user" ]
[ file where file.name == "cmd.exe" and agent.id != "8a4f526c" ]
[ process where stringContains(process.executable, "regsvr32") ]
"""
}

View File

@ -64,9 +64,9 @@ or sorted search requests.
[source,console]
--------------------------------------------------
POST /twitter/_forcemerge?max_num_segments=1
POST /my-index-000001/_forcemerge?max_num_segments=1
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
[role="xpack"]
[testenv="basic"]
@ -81,9 +81,9 @@ the query parameter `ignore_throttled=false`.
[source,console]
--------------------------------------------------
GET /twitter/_search?q=user:kimchy&ignore_throttled=false
GET /my-index-000001/_search?q=user.id:kimchy&ignore_throttled=false
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
[role="xpack"]
[testenv="basic"]
@ -95,16 +95,16 @@ Frozen indices are ordinary indices that use search throttling and a memory effi
[source,console]
--------------------------------------------------
GET /_cat/indices/twitter?v&h=i,sth
GET /_cat/indices/my-index-000001?v&h=i,sth
--------------------------------------------------
// TEST[s/^/PUT twitter\nPOST twitter\/_freeze\n/]
// TEST[s/^/PUT my-index-000001\nPOST my-index-000001\/_freeze\n/]
The response looks like:
[source,txt]
--------------------------------------------------
i sth
twitter true
i sth
my-index-000001 true
--------------------------------------------------
// TESTRESPONSE[non_json]

View File

@ -74,9 +74,9 @@ Adds an index block to an index.
[source,console]
--------------------------------------------------
PUT /twitter/_block/write
PUT /my-index-000001/_block/write
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
[discrete]

View File

@ -14,7 +14,7 @@ For instance the following example shows how to define a sort on a single field:
[source,console]
--------------------------------------------------
PUT twitter
PUT my-index-000001
{
"settings": {
"index": {
@ -39,7 +39,7 @@ It is also possible to sort the index by more than one field:
[source,console]
--------------------------------------------------
PUT twitter
PUT my-index-000001
{
"settings": {
"index": {

View File

@ -31,7 +31,7 @@ All of the above settings are _dynamic_ and can be set for each index using the
[source,console]
--------------------------------------------------
PUT /twitter/_settings
PUT /my-index-000001/_settings
{
"index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s",
@ -44,7 +44,7 @@ PUT /twitter/_settings
"index.search.slowlog.level": "info"
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
By default, none are enabled (set to `-1`). Levels (`warn`, `info`,
`debug`, `trace`) allow to control under which logging level the log
@ -141,7 +141,7 @@ All of the above settings are _dynamic_ and can be set for each index using the
[source,console]
--------------------------------------------------
PUT /twitter/_settings
PUT /my-index-000001/_settings
{
"index.indexing.slowlog.threshold.index.warn": "10s",
"index.indexing.slowlog.threshold.index.info": "5s",
@ -151,7 +151,7 @@ PUT /twitter/_settings
"index.indexing.slowlog.source": "1000"
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
By default Elasticsearch will log the first 1000 characters of the _source in
the slowlog. You can change that with `index.indexing.slowlog.source`. Setting

View File

@ -302,19 +302,23 @@ exist in the mapping:
[source,console]
--------------------------------------------------
PUT /test1
PUT /my-index-000001
{
"mappings": {
"properties": {
"user" : {
"type": "keyword"
"user": {
"properties": {
"id": {
"type": "keyword"
}
}
}
}
}
}
--------------------------------------------------
Now we can create an alias that uses a filter on field `user`:
Now we can create an alias that uses a filter on field `user.id`:
[source,console]
--------------------------------------------------
@ -323,7 +327,7 @@ POST /_aliases
"actions": [
{
"add": {
"index": "test1",
"index": "my-index-000001",
"alias": "alias2",
"filter": { "term": { "user.id": "kimchy" } }
}

View File

@ -141,7 +141,7 @@ PUT _component_template/template_1
"filter" : {
"term" : {"user.id" : "kimchy" }
},
"routing" : "kimchy"
"routing" : "shard-1"
},
"{index}-alias" : {} <1>
}

View File

@ -155,7 +155,7 @@ PUT /test
"filter": {
"term": { "user.id": "kimchy" }
},
"routing": "kimchy"
"routing": "shard-1"
}
}
}

View File

@ -138,7 +138,7 @@ PUT _component_template/template_1
"filter" : {
"term" : {"user.id" : "kimchy" }
},
"routing" : "kimchy"
"routing" : "shard-1"
},
"{index}-alias" : {} <1>
}

View File

@ -152,7 +152,7 @@ PUT _template/template_1
"filter" : {
"term" : {"user.id" : "kimchy" }
},
"routing" : "kimchy"
"routing" : "shard-1"
},
"{index}-alias" : {} <1>
}

View File

@ -155,7 +155,7 @@ PUT _index_template/template_1
"filter" : {
"term" : {"user.id" : "kimchy" }
},
"routing" : "kimchy"
"routing" : "shard-1"
},
"{index}-alias" : {} <1>
}

View File

@ -14,7 +14,7 @@ within the index. For this reason, it can be disabled as follows:
[source,console]
--------------------------------------------------
PUT tweets
PUT my-index-000001
{
"mappings": {
"_source": {

View File

@ -51,16 +51,16 @@ Controls the flood stage watermark, which defaults to 95%. {es} enforces a read-
NOTE: You cannot mix the usage of percentage values and byte values within
these settings. Either all values are set to percentage values, or all are set to byte values. This enforcement is so that {es} can validate that the settings are internally consistent, ensuring that the low disk threshold is less than the high disk threshold, and the high disk threshold is less than the flood stage threshold.
An example of resetting the read-only index block on the `twitter` index:
An example of resetting the read-only index block on the `my-index-000001` index:
[source,console]
--------------------------------------------------
PUT /twitter/_settings
PUT /my-index-000001/_settings
{
"index.blocks.read_only_allow_delete": null
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
--
// end::cluster-routing-flood-stage-tag[]

View File

@ -66,22 +66,22 @@ PUT _cluster/settings
==== Search a single remote cluster
The following <<search-search,search>> API request searches the
`twitter` index on a single remote cluster, `cluster_one`.
`my-index-000001` index on a single remote cluster, `cluster_one`.
[source,console]
--------------------------------------------------
GET /cluster_one:twitter/_search
GET /cluster_one:my-index-000001/_search
{
"query": {
"match": {
"user": "kimchy"
"user.id": "kimchy"
}
},
"_source": ["user", "message", "likes"]
"_source": ["user.id", "message", "http.response.status_code"]
}
--------------------------------------------------
// TEST[continued]
// TEST[setup:twitter]
// TEST[setup:my_index]
The API returns the following response:
@ -109,14 +109,21 @@ The API returns the following response:
"max_score": 1,
"hits": [
{
"_index": "cluster_one:twitter", <1>
"_index": "cluster_one:my-index-000001", <1>
"_type": "_doc",
"_id": "0",
"_score": 1,
"_source": {
"user": "kimchy",
"message": "trying out Elasticsearch",
"likes": 0
"user": {
"id": "kimchy"
},
"message": "GET /search HTTP/1.1 200 1070000",
"http": {
"response":
{
"status_code": 200
}
}
}
}
]
@ -134,7 +141,7 @@ The API returns the following response:
[[ccs-search-multi-remote-cluster]]
==== Search multiple remote clusters
The following <<search,search>> API request searches the `twitter` index on
The following <<search,search>> API request searches the `my-index-000001` index on
three clusters:
* Your local cluster
@ -142,14 +149,14 @@ three clusters:
[source,console]
--------------------------------------------------
GET /twitter,cluster_one:twitter,cluster_two:twitter/_search
GET /my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001/_search
{
"query": {
"match": {
"user": "kimchy"
"user.id": "kimchy"
}
},
"_source": ["user", "message", "likes"]
"_source": ["user.id", "message", "http.response.status_code"]
}
--------------------------------------------------
// TEST[continued]
@ -181,36 +188,57 @@ The API returns the following response:
"max_score": 1,
"hits": [
{
"_index": "twitter", <1>
"_index": "my-index-000001", <1>
"_type": "_doc",
"_id": "0",
"_score": 2,
"_source": {
"user": "kimchy",
"message": "trying out Elasticsearch",
"likes": 0
"user": {
"id": "kimchy"
},
"message": "GET /search HTTP/1.1 200 1070000",
"http": {
"response":
{
"status_code": 200
}
}
}
},
{
"_index": "cluster_one:twitter", <2>
"_index": "cluster_one:my-index-000001", <2>
"_type": "_doc",
"_id": "0",
"_score": 1,
"_source": {
"user": "kimchy",
"message": "trying out Elasticsearch",
"likes": 0
"user": {
"id": "kimchy"
},
"message": "GET /search HTTP/1.1 200 1070000",
"http": {
"response":
{
"status_code": 200
}
}
}
},
{
"_index": "cluster_two:twitter", <3>
"_index": "cluster_two:my-index-000001", <3>
"_type": "_doc",
"_id": "0",
"_score": 1,
"_source": {
"user": "kimchy",
"message": "trying out Elasticsearch",
"likes": 0
"user": {
"id": "kimchy"
},
"message": "GET /search HTTP/1.1 200 1070000",
"http": {
"response":
{
"status_code": 200
}
}
}
}
]

View File

@ -45,9 +45,9 @@ The cache can be expired manually with the <<indices-clearcache,`clear-cache` AP
[source,console]
------------------------
POST /kimchy,elasticsearch/_cache/clear?request=true
POST /my-index-000001,my-index-000002/_cache/clear?request=true
------------------------
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
// TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]
[discrete]
==== Enabling and disabling caching

View File

@ -39,10 +39,10 @@ POST _search
"query": {
"bool" : {
"must" : {
"term" : { "user" : "kimchy" }
"term" : { "user.id" : "kimchy" }
},
"filter": {
"term" : { "tag" : "tech" }
"term" : { "tags" : "production" }
},
"must_not" : {
"range" : {
@ -50,8 +50,8 @@ POST _search
}
},
"should" : [
{ "term" : { "tag" : "wow" } },
{ "term" : { "tag" : "elasticsearch" } }
{ "term" : { "tags" : "env1" } },
{ "term" : { "tags" : "deployed" } }
],
"minimum_should_match" : 1,
"boost" : 1.0

View File

@ -15,7 +15,7 @@ GET /_search
"query": {
"constant_score": {
"filter": {
"term": { "user": "kimchy" }
"term": { "user.id": "kimchy" }
},
"boost": 1.2
}

View File

@ -50,7 +50,7 @@ use the `must_not` <<query-dsl-bool-query, boolean query>> with the `exists`
query.
The following search returns documents that are missing an indexed value for
the `user` field.
the `user.id` field.
[source,console]
----
@ -60,7 +60,7 @@ GET /_search
"bool": {
"must_not": {
"exists": {
"field": "user"
"field": "user.id"
}
}
}

View File

@ -29,7 +29,7 @@ GET /_search
}
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
<1> See <<score-functions>> for a list of supported functions.
@ -64,7 +64,7 @@ GET /_search
}
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
<1> Boost for the whole query.
<2> See <<score-functions>> for a list of supported functions.
@ -151,7 +151,7 @@ GET /_search
}
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
[IMPORTANT]
====
@ -193,7 +193,7 @@ GET /_search
}
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
Note that unlike the `custom_score` query, the
score of the query is multiplied with the result of the script scoring. If
@ -251,7 +251,7 @@ GET /_search
}
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
[[function-field-value-factor]]
==== Field Value factor
@ -281,7 +281,7 @@ GET /_search
}
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
Which will translate into the following formula for scoring:
@ -383,7 +383,7 @@ GET /_search
"query": {
"function_score": {
"gauss": {
"date": {
"@timestamp": {
"origin": "2013-09-17", <1>
"scale": "10d",
"offset": "5d", <2>
@ -394,7 +394,7 @@ GET /_search
}
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
<1> The date format of the origin depends on the <<mapping-date-format,`format`>> defined in
your mapping. If you do not define the origin, the current time is used.

View File

@ -9,7 +9,7 @@ Returns documents that contain a specific prefix in a provided field.
[[prefix-query-ex-request]]
==== Example request
The following search returns documents where the `user` field contains a term
The following search returns documents where the `user.id` field contains a term
that begins with `ki`.
[source,console]
@ -18,7 +18,7 @@ GET /_search
{
"query": {
"prefix": {
"user": {
"user.id": {
"value": "ki"
}
}

View File

@ -292,17 +292,17 @@ need to write your query as `\(1\+1\)\=2`. When using JSON for the request body,
[source,console]
----
GET /twitter/_search
GET /my-index-000001/_search
{
"query" : {
"query_string" : {
"query" : "kimchy\\!",
"fields" : ["user"]
"fields" : ["user.id"]
}
}
}
----
// TEST[setup:twitter]
// TEST[setup:my_index]
The reserved characters are: `+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /`

View File

@ -14,7 +14,7 @@ characters, called operators. For a list of operators supported by the
[[regexp-query-ex-request]]
==== Example request
The following search returns documents where the `user` field contains any term
The following search returns documents where the `user.id` field contains any term
that begins with `k` and ends with `y`. The `.*` operators match any
characters of any length, including no characters. Matching
terms can include `ky`, `kay`, and `kimchy`.
@ -25,7 +25,7 @@ GET /_search
{
"query": {
"regexp": {
"user": {
"user.id": {
"value": "k.*y",
"flags": "ALL",
"max_determinized_states": 10000,

View File

@ -14,7 +14,7 @@ GET /_search
"query": {
"span_first": {
"match": {
"span_term": { "user": "kimchy" }
"span_term": { "user.id": "kimchy" }
},
"end": 3
}

View File

@ -12,7 +12,7 @@ Matches spans containing a term. The span term query maps to Lucene
GET /_search
{
"query": {
"span_term" : { "user" : "kimchy" }
"span_term" : { "user.id" : "kimchy" }
}
}
--------------------------------------------------
@ -24,7 +24,7 @@ A boost can also be associated with the query:
GET /_search
{
"query": {
"span_term" : { "user" : { "value" : "kimchy", "boost" : 2.0 } }
"span_term" : { "user.id" : { "value" : "kimchy", "boost" : 2.0 } }
}
}
--------------------------------------------------
@ -36,7 +36,7 @@ Or :
GET /_search
{
"query": {
"span_term" : { "user" : { "term" : "kimchy", "boost" : 2.0 } }
"span_term" : { "user.id" : { "term" : "kimchy", "boost" : 2.0 } }
}
}
--------------------------------------------------

View File

@ -30,8 +30,8 @@ GET /_search
{
"query": {
"term": {
"user": {
"value": "Kimchy",
"user.id": {
"value": "kimchy",
"boost": 1.0
}
}

View File

@ -12,8 +12,8 @@ except you can search for multiple values.
[[terms-query-ex-request]]
==== Example request
The following search returns documents where the `user` field contains `kimchy`
or `elasticsearch`.
The following search returns documents where the `user.id` field contains `kimchy`
or `elkbee`.
[source,console]
----
@ -21,7 +21,7 @@ GET /_search
{
"query": {
"terms": {
"user": [ "kimchy", "elasticsearch" ],
"user.id": [ "kimchy", "elkbee" ],
"boost": 1.0
}
}

View File

@ -13,7 +13,7 @@ combine wildcard operators with other characters to create a wildcard pattern.
[[wildcard-query-ex-request]]
==== Example request
The following search returns documents where the `user` field contains a term
The following search returns documents where the `user.id` field contains a term
that begins with `ki` and ends with `y`. These matching terms can include `kiy`,
`kity`, or `kimchy`.
@ -23,7 +23,7 @@ GET /_search
{
"query": {
"wildcard": {
"user": {
"user.id": {
"value": "ki*y",
"boost": 1.0,
"rewrite": "constant_score"

View File

@ -12,13 +12,13 @@ GET /_search
{
"query": {
"wrapper": {
"query": "eyJ0ZXJtIiA6IHsgInVzZXIiIDogIktpbWNoeSIgfX0=" <1>
"query": "eyJ0ZXJtIiA6IHsgInVzZXIuaWQiIDogImtpbWNoeSIgfX0=" <1>
}
}
}
--------------------------------------------------
<1> Base64 encoded string: `{"term" : { "user" : "Kimchy" }}`
<1> Base64 encoded string: `{"term" : { "user.id" : "kimchy" }}`
This query is more useful in the context of the Java high-level REST client or
transport client to also accept queries as json formatted string.

View File

@ -163,7 +163,7 @@ POST _scripts/calculate-score
}
}
-----------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
You may also specify a context as part of the url path to compile a
stored script against that specific context in the form of
@ -179,7 +179,7 @@ POST _scripts/calculate-score/score
}
}
-----------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
This same script can be retrieved with:
@ -193,7 +193,7 @@ Stored scripts can be used by specifying the `id` parameters as follows:
[source,console]
--------------------------------------------------
GET twitter/_search
GET my-index-000001/_search
{
"query": {
"script_score": {

View File

@ -11,26 +11,28 @@ exception of the <<search-explain>> endpoints.
When executing a search, Elasticsearch will pick the "best" copy of the data
based on the <<search-adaptive-replica,adaptive replica selection>> formula.
Which shards will be searched on can also be controlled by providing the
`routing` parameter. For example, when indexing tweets, the routing value can be
the user name:
`routing` parameter.
For example, the following indexing request routes documents to shard `1`:
[source,console]
--------------------------------------------------
POST /twitter/_doc?routing=kimchy
POST /my-index-000001/_doc?routing=1
{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
"@timestamp": "2099-11-15T13:12:00",
"message": "GET /search HTTP/1.1 200 1070000",
"user": {
"id": "kimchy"
}
}
--------------------------------------------------
In such a case, if we want to search only on the tweets for a specific
user, we can specify it as the routing, resulting in the search hitting
only the relevant shard:
Later, you can use the `routing` parameter in a search request to search only
the specified shard. The following search requests hits only shard `1`.
[source,console]
--------------------------------------------------
POST /twitter/_search?routing=kimchy
POST /my-index-000001/_search?routing=1
{
"query": {
"bool": {
@ -40,7 +42,7 @@ POST /twitter/_search?routing=kimchy
}
},
"filter": {
"term": { "user": "kimchy" }
"term": { "user.id": "kimchy" }
}
}
}
@ -102,7 +104,7 @@ POST /_search
"stats" : ["group1", "group2"]
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[setup:my_index]
[discrete]
[[global-search-timeout]]