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

This commit is contained in:
James Rodewig 2020-08-03 12:49:56 -04:00 committed by GitHub
parent 41a93d7fd8
commit ae01606785
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] [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 GET /_cluster/stats?human&pretty
-------------------------------------------------- --------------------------------------------------
// TEST[setup:twitter] // TEST[setup:my_index]
The API returns the following response: The API returns the following response:

View file

@ -57,7 +57,7 @@ operation that removes corrupted data from the shard.
[source,txt] [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. WARNING: Elasticsearch MUST be stopped before running this tool.

View file

@ -63,7 +63,7 @@ Example to delete with routing
[source,console] [source,console]
-------------------------------------------------- --------------------------------------------------
PUT /my-index-000001/_doc/1?routing=kimchy PUT /my-index-000001/_doc/1?routing=shard-1
{ {
"test": "test" "test": "test"
} }
@ -73,7 +73,7 @@ PUT /my-index-000001/_doc/1?routing=kimchy
[source,console] [source,console]
-------------------------------------------------- --------------------------------------------------
DELETE /my-index-000001/_doc/1?routing=kimchy DELETE /my-index-000001/_doc/1?routing=shard-1
-------------------------------------------------- --------------------------------------------------
// TEST[continued] // 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: `file` that meet the following conditions:
* A `file.name` of `cmd.exe` * A `file.name` of `cmd.exe`
* An `agent.id` other than `my_user` * An `agent.id` other than `8a4f526c`
[source,console] [source,console]
---- ----
GET /my-index-000001/_eql/search GET /my-index-000001/_eql/search
{ {
"query": """ "query": """
file where (file.name == "cmd.exe" and agent.id != "my_user") file where (file.name == "cmd.exe" and agent.id != "8a4f526c")
""" """
} }
---- ----
@ -614,7 +614,7 @@ that:
-- --
* An `event.category` of `file` * An `event.category` of `file`
* A `file.name` of `cmd.exe` * A `file.name` of `cmd.exe`
* An `agent.id` other than `my_user` * An `agent.id` other than `8a4f526c`
-- --
. Followed by an event with: . Followed by an event with:
+ +
@ -631,7 +631,7 @@ GET /my-index-000001/_eql/search
{ {
"query": """ "query": """
sequence by agent.id 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") ] [ process where stringContains(process.executable, "regsvr32") ]
""" """
} }

View file

@ -64,9 +64,9 @@ or sorted search requests.
[source,console] [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"] [role="xpack"]
[testenv="basic"] [testenv="basic"]
@ -81,9 +81,9 @@ the query parameter `ignore_throttled=false`.
[source,console] [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"] [role="xpack"]
[testenv="basic"] [testenv="basic"]
@ -95,16 +95,16 @@ Frozen indices are ordinary indices that use search throttling and a memory effi
[source,console] [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: The response looks like:
[source,txt] [source,txt]
-------------------------------------------------- --------------------------------------------------
i sth i sth
twitter true my-index-000001 true
-------------------------------------------------- --------------------------------------------------
// TESTRESPONSE[non_json] // TESTRESPONSE[non_json]

View file

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

View file

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

View file

@ -29,7 +29,7 @@ All of the above settings are _dynamic_ and can be set for each index using the
[source,console] [source,console]
-------------------------------------------------- --------------------------------------------------
PUT /twitter/_settings PUT /my-index-000001/_settings
{ {
"index.search.slowlog.threshold.query.warn": "10s", "index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s", "index.search.slowlog.threshold.query.info": "5s",
@ -41,7 +41,7 @@ PUT /twitter/_settings
"index.search.slowlog.threshold.fetch.trace": "200ms" "index.search.slowlog.threshold.fetch.trace": "200ms"
} }
-------------------------------------------------- --------------------------------------------------
// TEST[setup:twitter] // TEST[setup:my_index]
By default thresholds are disabled (set to `-1`). By default thresholds are disabled (set to `-1`).
@ -108,7 +108,7 @@ All of the above settings are _dynamic_ and can be set for each index using the
[source,console] [source,console]
-------------------------------------------------- --------------------------------------------------
PUT /twitter/_settings PUT /my-index-000001/_settings
{ {
"index.indexing.slowlog.threshold.index.warn": "10s", "index.indexing.slowlog.threshold.index.warn": "10s",
"index.indexing.slowlog.threshold.index.info": "5s", "index.indexing.slowlog.threshold.index.info": "5s",
@ -117,7 +117,7 @@ PUT /twitter/_settings
"index.indexing.slowlog.source": "1000" "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 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 the slowlog. You can change that with `index.indexing.slowlog.source`. Setting

View file

@ -302,19 +302,23 @@ exist in the mapping:
[source,console] [source,console]
-------------------------------------------------- --------------------------------------------------
PUT /test1 PUT /my-index-000001
{ {
"mappings": { "mappings": {
"properties": { "properties": {
"user": { "user": {
"properties": {
"id": {
"type": "keyword" "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] [source,console]
-------------------------------------------------- --------------------------------------------------
@ -323,7 +327,7 @@ POST /_aliases
"actions": [ "actions": [
{ {
"add": { "add": {
"index": "test1", "index": "my-index-000001",
"alias": "alias2", "alias": "alias2",
"filter": { "term": { "user.id": "kimchy" } } "filter": { "term": { "user.id": "kimchy" } }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -14,7 +14,7 @@ within the index. For this reason, it can be disabled as follows:
[source,console] [source,console]
-------------------------------------------------- --------------------------------------------------
PUT tweets PUT my-index-000001
{ {
"mappings": { "mappings": {
"_source": { "_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 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. 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] [source,console]
-------------------------------------------------- --------------------------------------------------
PUT /twitter/_settings PUT /my-index-000001/_settings
{ {
"index.blocks.read_only_allow_delete": null "index.blocks.read_only_allow_delete": null
} }
-------------------------------------------------- --------------------------------------------------
// TEST[setup:twitter] // TEST[setup:my_index]
-- --
// end::cluster-routing-flood-stage-tag[] // end::cluster-routing-flood-stage-tag[]

View file

@ -66,22 +66,22 @@ PUT _cluster/settings
==== Search a single remote cluster ==== Search a single remote cluster
The following <<search-search,search>> API request searches the 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] [source,console]
-------------------------------------------------- --------------------------------------------------
GET /cluster_one:twitter/_search GET /cluster_one:my-index-000001/_search
{ {
"query": { "query": {
"match": { "match": {
"user": "kimchy" "user.id": "kimchy"
} }
}, },
"_source": ["user", "message", "likes"] "_source": ["user.id", "message", "http.response.status_code"]
} }
-------------------------------------------------- --------------------------------------------------
// TEST[continued] // TEST[continued]
// TEST[setup:twitter] // TEST[setup:my_index]
The API returns the following response: The API returns the following response:
@ -109,13 +109,20 @@ The API returns the following response:
"max_score": 1, "max_score": 1,
"hits": [ "hits": [
{ {
"_index": "cluster_one:twitter", <1> "_index": "cluster_one:my-index-000001", <1>
"_id": "0", "_id": "0",
"_score": 1, "_score": 1,
"_source": { "_source": {
"user": "kimchy", "user": {
"message": "trying out Elasticsearch", "id": "kimchy"
"likes": 0 },
"message": "GET /search HTTP/1.1 200 1070000",
"http": {
"response":
{
"status_code": 200
}
}
} }
} }
] ]
@ -133,7 +140,7 @@ The API returns the following response:
[[ccs-search-multi-remote-cluster]] [[ccs-search-multi-remote-cluster]]
==== Search multiple remote clusters ==== 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: three clusters:
* Your local cluster * Your local cluster
@ -141,14 +148,14 @@ three clusters:
[source,console] [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": { "query": {
"match": { "match": {
"user": "kimchy" "user.id": "kimchy"
} }
}, },
"_source": ["user", "message", "likes"] "_source": ["user.id", "message", "http.response.status_code"]
} }
-------------------------------------------------- --------------------------------------------------
// TEST[continued] // TEST[continued]
@ -180,33 +187,54 @@ The API returns the following response:
"max_score": 1, "max_score": 1,
"hits": [ "hits": [
{ {
"_index": "twitter", <1> "_index": "my-index-000001", <1>
"_id": "0", "_id": "0",
"_score": 2, "_score": 2,
"_source": { "_source": {
"user": "kimchy", "user": {
"message": "trying out Elasticsearch", "id": "kimchy"
"likes": 0 },
"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>
"_id": "0", "_id": "0",
"_score": 1, "_score": 1,
"_source": { "_source": {
"user": "kimchy", "user": {
"message": "trying out Elasticsearch", "id": "kimchy"
"likes": 0 },
"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>
"_id": "0", "_id": "0",
"_score": 1, "_score": 1,
"_source": { "_source": {
"user": "kimchy", "user": {
"message": "trying out Elasticsearch", "id": "kimchy"
"likes": 0 },
"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] [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] [discrete]
==== Enabling and disabling caching ==== Enabling and disabling caching

View file

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

View file

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

View file

@ -50,7 +50,7 @@ use the `must_not` <<query-dsl-bool-query, boolean query>> with the `exists`
query. query.
The following search returns documents that are missing an indexed value for The following search returns documents that are missing an indexed value for
the `user` field. the `user.id` field.
[source,console] [source,console]
---- ----
@ -60,7 +60,7 @@ GET /_search
"bool": { "bool": {
"must_not": { "must_not": {
"exists": { "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. <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. <1> Boost for the whole query.
<2> See <<score-functions>> for a list of supported functions. <2> See <<score-functions>> for a list of supported functions.
@ -151,7 +151,7 @@ GET /_search
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[setup:twitter] // TEST[setup:my_index]
[IMPORTANT] [IMPORTANT]
==== ====
@ -193,7 +193,7 @@ GET /_search
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[setup:twitter] // TEST[setup:my_index]
Note that unlike the `custom_score` query, the Note that unlike the `custom_score` query, the
score of the query is multiplied with the result of the script scoring. If 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]] [[function-field-value-factor]]
==== 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: Which will translate into the following formula for scoring:
@ -383,7 +383,7 @@ GET /_search
"query": { "query": {
"function_score": { "function_score": {
"gauss": { "gauss": {
"date": { "@timestamp": {
"origin": "2013-09-17", <1> "origin": "2013-09-17", <1>
"scale": "10d", "scale": "10d",
"offset": "5d", <2> "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 <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. 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]] [[prefix-query-ex-request]]
==== Example 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`. that begins with `ki`.
[source,console] [source,console]
@ -18,7 +18,7 @@ GET /_search
{ {
"query": { "query": {
"prefix": { "prefix": {
"user": { "user.id": {
"value": "ki" "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] [source,console]
---- ----
GET /twitter/_search GET /my-index-000001/_search
{ {
"query" : { "query" : {
"query_string" : { "query_string" : {
"query" : "kimchy\\!", "query" : "kimchy\\!",
"fields" : ["user"] "fields" : ["user.id"]
} }
} }
} }
---- ----
// TEST[setup:twitter] // TEST[setup:my_index]
The reserved characters are: `+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /` 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]] [[regexp-query-ex-request]]
==== Example 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 that begins with `k` and ends with `y`. The `.*` operators match any
characters of any length, including no characters. Matching characters of any length, including no characters. Matching
terms can include `ky`, `kay`, and `kimchy`. terms can include `ky`, `kay`, and `kimchy`.
@ -25,7 +25,7 @@ GET /_search
{ {
"query": { "query": {
"regexp": { "regexp": {
"user": { "user.id": {
"value": "k.*y", "value": "k.*y",
"flags": "ALL", "flags": "ALL",
"max_determinized_states": 10000, "max_determinized_states": 10000,

View file

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

View file

@ -12,7 +12,7 @@ Matches spans containing a term. The span term query maps to Lucene
GET /_search GET /_search
{ {
"query": { "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 GET /_search
{ {
"query": { "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 GET /_search
{ {
"query": { "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": { "query": {
"term": { "term": {
"user": { "user.id": {
"value": "Kimchy", "value": "kimchy",
"boost": 1.0 "boost": 1.0
} }
} }

View file

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

View file

@ -13,7 +13,7 @@ combine wildcard operators with other characters to create a wildcard pattern.
[[wildcard-query-ex-request]] [[wildcard-query-ex-request]]
==== Example 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`, that begins with `ki` and ends with `y`. These matching terms can include `kiy`,
`kity`, or `kimchy`. `kity`, or `kimchy`.
@ -23,7 +23,7 @@ GET /_search
{ {
"query": { "query": {
"wildcard": { "wildcard": {
"user": { "user.id": {
"value": "ki*y", "value": "ki*y",
"boost": 1.0, "boost": 1.0,
"rewrite": "constant_score" "rewrite": "constant_score"

View file

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