Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to one shard #30539

Merged
merged 17 commits into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
* warning every time. */
current.println(" - skip:")
current.println(" features: ")
current.println(" - default_shards")
current.println(" - stash_in_key")
current.println(" - stash_in_path")
current.println(" - stash_path_replace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public void testSearchWithMatrixStats() throws IOException {
MatrixStats matrixStats = searchResponse.getAggregations().get("agg1");
assertEquals(5, matrixStats.getFieldCount("num"));
assertEquals(56d, matrixStats.getMean("num"), 0d);
assertEquals(1830d, matrixStats.getVariance("num"), 0d);
assertEquals(1830.0000000000002, matrixStats.getVariance("num"), 0d);
assertEquals(0.09340198804973046, matrixStats.getSkewness("num"), 0d);
assertEquals(1.2741646510794589, matrixStats.getKurtosis("num"), 0d);
assertEquals(5, matrixStats.getFieldCount("num2"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@

import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.junit.Before;

import java.io.IOException;

import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.startsWith;

/**
* Tests for the "Location" header returned when returning {@code 201 CREATED}.
*/
public class CreatedLocationHeaderIT extends ESRestTestCase {

public void testCreate() throws IOException {
locationTestCase("PUT", "test/test/1");
}
Expand All @@ -54,8 +58,11 @@ public void testUpsert() throws IOException {
private void locationTestCase(String method, String url) throws IOException {
locationTestCase(client().performRequest(method, url, emptyMap(),
new StringEntity("{\"test\": \"test\"}", ContentType.APPLICATION_JSON)));
// we have to delete the index otherwise the second indexing request will route to the single shard and not produce a 201
final Response response = client().performRequest(new Request("DELETE", "test"));
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
locationTestCase(client().performRequest(method, url + "?routing=cat", emptyMap(),
new StringEntity("{\"test\": \"test\"}", ContentType.APPLICATION_JSON)));
new StringEntity("{\"test\": \"test\"}", ContentType.APPLICATION_JSON)));
}

private void locationTestCase(Response response) throws IOException {
Expand All @@ -65,4 +72,5 @@ private void locationTestCase(Response response) throws IOException {
Response getResponse = client().performRequest("GET", location);
assertEquals(singletonMap("test", "test"), entityAsMap(getResponse).get("_source"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ Possible response:
"took": 25,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"total": 1,
"successful": 1,
"skipped" : 0,
"failed": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ The response for the above aggregation:
"aggregations": {
"centroid": {
"location": {
"lat": 51.00982963806018,
"lon": 3.9662131061777472
"lat": 51.009829603135586,
"lon": 3.9662130642682314
},
"count": 6
}
Expand Down Expand Up @@ -113,8 +113,8 @@ The response for the above aggregation:
"doc_count": 3,
"centroid": {
"location": {
"lat": 52.371655656024814,
"lon": 4.909563297405839
"lat": 52.371655642054975,
"lon": 4.9095632415264845
},
"count": 3
}
Expand All @@ -125,7 +125,7 @@ The response for the above aggregation:
"centroid": {
"location": {
"lat": 48.86055548675358,
"lon": 2.3316944623366
"lon": 2.331694420427084
},
"count": 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ The output from the above is:
"timed_out": false,
"took": $body.took,
"_shards": {
"total": 5,
"successful": 5,
"total": 1,
"successful": 1,
"skipped" : 0,
"failed": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ GET my_index/_search
"took": $body.took,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"total": 1,
"successful": 1,
"skipped" : 0,
"failed": 0
},
Expand Down
6 changes: 1 addition & 5 deletions docs/reference/api-conventions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,7 @@ Responds:
"indices": {
"twitter": {
"shards": {
"0": [{"state": "STARTED"}, {"state": "UNASSIGNED"}],
"1": [{"state": "STARTED"}, {"state": "UNASSIGNED"}],
"2": [{"state": "STARTED"}, {"state": "UNASSIGNED"}],
"3": [{"state": "STARTED"}, {"state": "UNASSIGNED"}],
"4": [{"state": "STARTED"}, {"state": "UNASSIGNED"}]
"0": [{"state": "STARTED"}, {"state": "UNASSIGNED"}]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cat/allocation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Might respond with:
[source,txt]
--------------------------------------------------
shards disk.indices disk.used disk.avail disk.total disk.percent host ip node
5 260b 47.3gb 43.4gb 100.7gb 46 127.0.0.1 127.0.0.1 CSUXak2
1 260b 47.3gb 43.4gb 100.7gb 46 127.0.0.1 127.0.0.1 CSUXak2
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/ s/46/\\d+/]
// TESTRESPONSE[s/CSUXak2/.+/ _cat]
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/cat/health.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GET /_cat/health?v
[source,txt]
--------------------------------------------------
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1475871424 16:17:04 elasticsearch green 1 1 5 5 0 0 0 0 - 100.0%
1475871424 16:17:04 elasticsearch green 1 1 1 1 0 0 0 0 - 100.0%
--------------------------------------------------
// TESTRESPONSE[s/1475871424 16:17:04/\\d+ \\d+:\\d+:\\d+/]
// TESTRESPONSE[s/elasticsearch/[^ ]+/ s/0 -/\\d+ (-|\\d+(\\.\\d+)?[ms]+)/ _cat]
Expand All @@ -33,7 +33,7 @@ which looks like:
[source,txt]
--------------------------------------------------
cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
elasticsearch green 1 1 5 5 0 0 0 0 - 100.0%
elasticsearch green 1 1 1 1 0 0 0 0 - 100.0%
--------------------------------------------------
// TESTRESPONSE[s/elasticsearch/[^ ]+/ s/0 -/\\d+ (-|\\d+(\\.\\d+)?[ms]+)/ _cat]

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/cat/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Might respond with:
--------------------------------------------------
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 5 0 0 0 260b 260b
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ _cat]
Expand Down Expand Up @@ -81,7 +81,7 @@ Which looks like:
--------------------------------------------------
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 5 0 0 0 260b 260b
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ _cat]
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/cat/segments.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ might look like:
["source","txt",subs="attributes,callouts"]
--------------------------------------------------
index shard prirep ip segment generation docs.count docs.deleted size size.memory committed searchable version compound
test 4 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
test1 4 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
test 0 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
test1 0 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
--------------------------------------------------
// TESTRESPONSE[s/3kb/\\d+(\\.\\d+)?[mk]?b/ s/2042/\\d+/ _cat]

Expand Down
6 changes: 3 additions & 3 deletions docs/reference/cluster/health.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Returns this:
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 5,
"active_shards" : 5,
"active_primary_shards" : 1,
"active_shards" : 1,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"unassigned_shards" : 1,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch": 0,
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ And the response:
[source,txt]
--------------------------------------------------
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open customer 95SQ4TSUT7mWBT7VNHH67A 5 1 0 0 260b 260b
yellow open customer 95SQ4TSUT7mWBT7VNHH67A 1 1 0 0 260b 260b
--------------------------------------------------
// TESTRESPONSE[s/95SQ4TSUT7mWBT7VNHH67A/.+/ s/260b/\\d+\\.?\\d?k?b/ _cat]

Expand Down
34 changes: 17 additions & 17 deletions docs/reference/how-to/recipes/stemming.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,31 @@ GET index/_search
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"total": 1,
"successful": 1,
"skipped" : 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0.2876821,
"max_score": 0.18232156,
"hits": [
{
"_index": "index",
"_type": "_doc",
"_id": "2",
"_score": 0.2876821,
"_id": "1",
"_score": 0.18232156,
"_source": {
"body": "A pair of skis"
"body": "Ski resort"
}
},
{
"_index": "index",
"_type": "_doc",
"_id": "1",
"_score": 0.2876821,
"_id": "2",
"_score": 0.18232156,
"_source": {
"body": "Ski resort"
"body": "A pair of skis"
}
}
]
Expand Down Expand Up @@ -136,20 +136,20 @@ GET index/_search
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"total": 1,
"successful": 1,
"skipped" : 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.2876821,
"max_score": 0.80259144,
"hits": [
{
"_index": "index",
"_type": "_doc",
"_id": "1",
"_score": 0.2876821,
"_score": 0.80259144,
"_source": {
"body": "Ski resort"
}
Expand Down Expand Up @@ -193,20 +193,20 @@ GET index/_search
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"total": 1,
"successful": 1,
"skipped" : 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.2876821,
"max_score": 0.80259144,
"hits": [
{
"_index": "index",
"_type": "_doc",
"_id": "1",
"_score": 0.2876821,
"_score": 0.80259144,
"_source": {
"body": "Ski resort"
}
Expand Down
10 changes: 1 addition & 9 deletions docs/reference/indices/flush.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ which returns something similar to:
"num_docs" : 0
}
}
],
"1": ...,
"2": ...,
"3": ...,
"4": ...
]
}
}
}
Expand All @@ -120,10 +116,6 @@ which returns something similar to:
// TESTRESPONSE[s/"translog_uuid" : "hnOG3xFcTDeoI_kvvvOdNA"/"translog_uuid": $body.indices.twitter.shards.0.0.commit.user_data.translog_uuid/]
// TESTRESPONSE[s/"history_uuid" : "XP7KDJGiS1a2fHYiFL5TXQ"/"history_uuid": $body.indices.twitter.shards.0.0.commit.user_data.history_uuid/]
// TESTRESPONSE[s/"sync_id" : "AVvFY-071siAOuFGEO9P"/"sync_id": $body.indices.twitter.shards.0.0.commit.user_data.sync_id/]
// TESTRESPONSE[s/"1": \.\.\./"1": $body.indices.twitter.shards.1/]
// TESTRESPONSE[s/"2": \.\.\./"2": $body.indices.twitter.shards.2/]
// TESTRESPONSE[s/"3": \.\.\./"3": $body.indices.twitter.shards.3/]
// TESTRESPONSE[s/"4": \.\.\./"4": $body.indices.twitter.shards.4/]
<1> the `sync id` marker

[float]
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/indices/shrink-index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PUT /my_source_index/_settings
}
--------------------------------------------------
// CONSOLE
// TEST[s/^/PUT my_source_index\n/]
// TEST[s/^/PUT my_source_index\n{"settings":{"index.number_of_shards":2}}\n/]
<1> Forces the relocation of a copy of each shard to the node with name
`shrink_node_name`. See <<shard-allocation-filtering>> for more options.

Expand Down Expand Up @@ -110,7 +110,7 @@ POST my_source_index/_shrink/my_target_index
}
--------------------------------------------------
// CONSOLE
// TEST[s/^/PUT my_source_index\n{"settings": {"index.blocks.write": true}}\n/]
// TEST[s/^/PUT my_source_index\n{"settings": {"index.number_of_shards":5,"index.blocks.write": true}}\n/]

<1> The number of shards in the target index. This must be a factor of the
number of shards in the source index.
Expand Down
Loading