Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit e1688d9

Browse files
committed
First round of phase 2 changes to sync up with version 2.x.
1 parent 25c4adc commit e1688d9

32 files changed

+212
-167
lines changed

010_Intro/10_Installing_ES.asciidoc

+16-21
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,30 @@ You should see a response like this:
5454
[source,js]
5555
--------------------------------------------------
5656
{
57-
"status": 200,
58-
"name": "Shrunken Bones",
59-
"version": {
60-
"number": "1.4.0",
61-
"lucene_version": "4.10"
62-
},
63-
"tagline": "You Know, for Search"
57+
"name" : "Tom Foster",
58+
"cluster_name" : "elasticsearch",
59+
"version" : {
60+
"number" : "2.1.0",
61+
"build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87",
62+
"build_timestamp" : "2015-11-18T22:40:03Z",
63+
"build_snapshot" : false,
64+
"lucene_version" : "5.3.1"
65+
},
66+
"tagline" : "You Know, for Search"
6467
}
6568
--------------------------------------------------
6669
// SENSE: 010_Intro/10_Info.json
6770

68-
This means that your Elasticsearch _cluster_ is up and running, and we can
69-
start experimenting with it.
71+
This means that you have an Elasticsearch node up and running, and you can
72+
start experimenting with it. A _node_ is a running instance of Elasticsearch.
73+
((("nodes", "defined"))) A _cluster_ is ((("clusters", "defined")))a group of
74+
nodes with the same `cluster.name` that are working together to share data
75+
and to provide failover and scale. (A single node, however, can form a cluster
76+
all by itself.)
7077

7178
TIP: See that View in Sense link at the bottom of the example? <<sense, Install the Sense console>>
7279
to run the examples in this book against your own Elasticsearch cluster and view the results.
7380

74-
A _node_ is a running instance of Elasticsearch.((("nodes", "defined"))) A _cluster_ is ((("clusters", "defined")))a group of
75-
nodes with the same `cluster.name` that are working together to share data
76-
and to provide failover and scale, although a single node can form a cluster
77-
all by itself.
78-
79-
You should change the default `cluster.name` to something appropriate to you,
80-
like your own name, to stop ((("clusters", "changing default name")))your nodes from trying to join another cluster on
81-
the same network with the same name!
82-
83-
You can do this by editing the `elasticsearch.yml` file in the `config/`
84-
directory and then restarting Elasticsearch.
85-
8681
When Elasticsearch is running in the foreground, you can stop it by pressing Ctrl-C.
8782

8883
[[sense]]

020_Distributed_Cluster/15_Add_an_index.asciidoc

+17-12
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,30 @@ If we were to check the
6565
[source,js]
6666
--------------------------------------------------
6767
{
68-
"cluster_name": "elasticsearch",
69-
"status": "yellow", <1>
70-
"timed_out": false,
71-
"number_of_nodes": 1,
72-
"number_of_data_nodes": 1,
73-
"active_primary_shards": 3,
74-
"active_shards": 3,
75-
"relocating_shards": 0,
76-
"initializing_shards": 0,
77-
"unassigned_shards": 3 <2>
68+
"cluster_name": "elasticsearch",
69+
"status": "yellow", <1>
70+
"timed_out": false,
71+
"number_of_nodes": 1,
72+
"number_of_data_nodes": 1,
73+
"active_primary_shards": 3,
74+
"active_shards": 3,
75+
"relocating_shards": 0,
76+
"initializing_shards": 0,
77+
"unassigned_shards": 3, <2>
78+
"delayed_unassigned_shards": 0,
79+
"number_of_pending_tasks": 0,
80+
"number_of_in_flight_fetch": 0,
81+
"task_max_waiting_in_queue_millis": 0,
82+
"active_shards_percent_as_number": 50
7883
}
7984
--------------------------------------------------
8085

8186
<1> Cluster `status` is `yellow`.
82-
<2> Our three replica shards have not been allocated to a node.
87+
<2> The replica shards have not been allocated to a node.
8388

8489
A cluster health of `yellow` means that all _primary_ shards are up and
8590
running (the cluster is capable of serving any request successfully) but
86-
not all _replica_ shards are active. In fact, all three of our replica shards
91+
not all _replica_ shards are active. In fact, all three replica shards
8792
are currently `unassigned`&#x2014;they haven't been allocated to a node. It
8893
doesn't make sense to store copies of the same data on the same node. If we
8994
were to lose that node, we would lose all copies of our data.

020_Distributed_Cluster/20_Add_failover.asciidoc

+21-15
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ in exactly the same way as you started the first one (see
1212
<<running-elasticsearch>>), and from the same directory. Multiple nodes can
1313
share the same directory.
1414
15-
As long as the second node has the same `cluster.name` as the first node (see
16-
the `./config/elasticsearch.yml` file), it should automatically discover and
17-
join the cluster run by the first node. If it doesn't, check the logs to find
18-
out what went wrong. It may be that multicast is disabled on your network, or
19-
that a firewall is preventing your nodes from communicating.
15+
When you run a second node on the same machine, it automatically discovers
16+
and joins the cluster as long as it has the same `cluster.name` as the first node (see
17+
the `./config/elasticsearch.yml` file). However, for nodes running on different machines
18+
to join the same cluster, you need to configure a list of unicast hosts the nodes can contact
19+
to join the cluster. For more information about how Elasticsearch nodes find eachother, see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery-zen.html[Zen Discovery]
20+
in the Elasticsearch Reference.
2021
2122
***************************************
2223

@@ -38,16 +39,21 @@ shards (all three primary shards and all three replica shards) are active:
3839
[source,js]
3940
--------------------------------------------------
4041
{
41-
"cluster_name": "elasticsearch",
42-
"status": "green", <1>
43-
"timed_out": false,
44-
"number_of_nodes": 2,
45-
"number_of_data_nodes": 2,
46-
"active_primary_shards": 3,
47-
"active_shards": 6,
48-
"relocating_shards": 0,
49-
"initializing_shards": 0,
50-
"unassigned_shards": 0
42+
"cluster_name": "elasticsearch",
43+
"status": "green", <1>
44+
"timed_out": false,
45+
"number_of_nodes": 2,
46+
"number_of_data_nodes": 2,
47+
"active_primary_shards": 3,
48+
"active_shards": 6,
49+
"relocating_shards": 0,
50+
"initializing_shards": 0,
51+
"unassigned_shards": 0,
52+
"delayed_unassigned_shards": 0,
53+
"number_of_pending_tasks": 0,
54+
"number_of_in_flight_fetch": 0,
55+
"task_max_waiting_in_queue_millis": 0,
56+
"active_shards_percent_as_number": 100
5157
}
5258
--------------------------------------------------
5359
<1> Cluster `status` is `green`.

060_Distributed_Search/15_Search_options.asciidoc

+5-31
Original file line numberDiff line numberDiff line change
@@ -82,40 +82,14 @@ discuss it in detail in <<scale>>.
8282
[[search-type]]
8383
==== search_type
8484

85-
While `query_then_fetch` is the default((("query_then_fetch search type")))((("search options", "search_type")))((("search_type"))) search type, other search types can
86-
be specified for particular purposes, for example:
85+
The default search type is `query_then_fetch` ((("query_then_fetch search type")))((("search options", "search_type")))((("search_type"))). In some cases, you might want to explicitly set the `search_type`
86+
to `dfs_query_then_fetch` to improve the accuracy of relevance scoring:
8787

8888
[source,js]
8989
--------------------------------------------------
90-
GET /_search?search_type=count
90+
GET /_search?search_type=dfs_query_then_fetch
9191
--------------------------------------------------
9292

93-
`count`::
94-
95-
The `count` search type has only a `query` phase.((("count search type"))) It can be used when you
96-
don't need search results, just a document count or
97-
<<aggregations,aggregations>> on documents matching the query.
98-
99-
`query_and_fetch`::
100-
101-
The `query_and_fetch` search type ((("query_and_fetch serch type")))combines the query and fetch phases into a
102-
single step. This is an internal optimization that is used when a search
103-
request targets a single shard only, such as when a
104-
<<search-routing,`routing`>> value has been specified. While you can choose
105-
to use this search type manually, it is almost never useful to do so.
106-
107-
`dfs_query_then_fetch` and `dfs_query_and_fetch`::
108-
109-
The `dfs` search types((("dfs search types"))) have a prequery phase that fetches the term
110-
frequencies from all involved shards in order to calculate global term
93+
The `dfs_query_then_fetch` search type has a prequery phase that fetches the term
94+
frequencies from all involved shards to calculate global term
11195
frequencies. We discuss this further in <<relevance-is-broken>>.
112-
113-
`scan`::
114-
115-
The `scan` search type is((("scan search type"))) used in conjunction with the `scroll` API ((("scroll API")))to
116-
retrieve large numbers of results efficiently. It does this by disabling
117-
sorting. We discuss _scan-and-scroll_ in the next section.
118-
119-
120-
121-

300_Aggregations/20_basic_example.asciidoc

+11-8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ using a simple aggregation. We will do this using a `terms` bucket:
4646

4747
[source,js]
4848
--------------------------------------------------
49-
GET /cars/transactions/_search?search_type=count
49+
GET /cars/transactions/_search
5050
{
51-
"aggs" : { <1>
52-
"colors" : { <2>
51+
"size" : 0,
52+
"aggs" : {
53+
"popular_colors" : {
5354
"terms" : {
54-
"field" : "color" <3>
55+
"field" : "color"
5556
}
5657
}
5758
}
@@ -71,9 +72,11 @@ in <<_scoping_aggregations>>.
7172

7273
[NOTE]
7374
=========================
74-
You'll notice that we used the `count` <<search-type,search_type>>.((("count search type")))
75-
Because we don't care about search results--the aggregation totals--the
76-
`count` search_type will be faster because it omits the fetch phase.
75+
You'll notice that we set the `size` to zero. We
76+
don't care about the search results themselves and
77+
returning zero hits speeds up the query. Setting
78+
`size: 0` is the equivalent of using the `count`
79+
search type in Elasticsearch 1.x.
7780
=========================
7881

7982
Next we define a name for our aggregation. Naming is up to you;
@@ -115,7 +118,7 @@ Let's execute that aggregation and take a look at the results:
115118
}
116119
}
117120
--------------------------------------------------
118-
<1> No search hits are returned because we used the `search_type=count` parameter
121+
<1> No search hits are returned because we set the `size` parameter
119122
<2> Our `colors` aggregation is returned as part of the `aggregations` field.
120123
<3> The `key` to each bucket corresponds to a unique term found in the `color` field.
121124
It also always includes `doc_count`, which tells us the number of docs containing the term.

300_Aggregations/21_add_metric.asciidoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Let's go ahead and add ((("average metric")))an `average` metric to our car exam
1414

1515
[source,js]
1616
--------------------------------------------------
17-
GET /cars/transactions/_search?search_type=count
17+
GET /cars/transactions/_search
1818
{
19+
"size" : 0,
1920
"aggs": {
2021
"colors": {
2122
"terms": {

300_Aggregations/22_nested_bucket.asciidoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ color:
1212

1313
[source,js]
1414
--------------------------------------------------
15-
GET /cars/transactions/_search?search_type=count
15+
GET /cars/transactions/_search
1616
{
17+
"size" : 0,
1718
"aggs": {
1819
"colors": {
1920
"terms": {

300_Aggregations/23_extra_metrics.asciidoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ max price for each make:
99

1010
[source,js]
1111
--------------------------------------------------
12-
GET /cars/transactions/_search?search_type=count
12+
GET /cars/transactions/_search
1313
{
14+
"size" : 0,
1415
"aggs": {
1516
"colors": {
1617
"terms": {

300_Aggregations/30_histogram.asciidoc

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ To do this, we use a `histogram` and a nested `sum` metric:
2020

2121
[source,js]
2222
--------------------------------------------------
23-
GET /cars/transactions/_search?search_type=count
23+
GET /cars/transactions/_search
2424
{
25+
"size" : 0,
2526
"aggs":{
2627
"price":{
2728
"histogram":{ <1>
@@ -119,8 +120,9 @@ an `extended_stats` ((("extended_stats metric")))metric:
119120

120121
[source,js]
121122
----
122-
GET /cars/transactions/_search?search_type=count
123+
GET /cars/transactions/_search
123124
{
125+
"size" : 0,
124126
"aggs": {
125127
"makes": {
126128
"terms": {

300_Aggregations/35_date_histogram.asciidoc

+6-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ how many cars were sold each month?
4141

4242
[source,js]
4343
--------------------------------------------------
44-
GET /cars/transactions/_search?search_type=count
44+
GET /cars/transactions/_search
4545
{
46+
"size" : 0,
4647
"aggs": {
4748
"sales": {
4849
"date_histogram": {
@@ -136,8 +137,9 @@ additional parameters that will provide this behavior:
136137

137138
[source,js]
138139
--------------------------------------------------
139-
GET /cars/transactions/_search?search_type=count
140+
GET /cars/transactions/_search
140141
{
142+
"size" : 0,
141143
"aggs": {
142144
"sales": {
143145
"date_histogram": {
@@ -188,8 +190,9 @@ which car type is bringing in the most money to our business:
188190

189191
[source,js]
190192
--------------------------------------------------
191-
GET /cars/transactions/_search?search_type=count
193+
GET /cars/transactions/_search
192194
{
195+
"size" : 0,
193196
"aggs": {
194197
"sales": {
195198
"date_histogram": {

300_Aggregations/40_scope.asciidoc

+9-7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Let's look at one of our first aggregation examples:
1515

1616
[source,js]
1717
--------------------------------------------------
18-
GET /cars/transactions/_search?search_type=count
18+
GET /cars/transactions/_search
1919
{
20+
"size" : 0,
2021
"aggs" : {
2122
"colors" : {
2223
"terms" : {
@@ -34,8 +35,9 @@ query is internally translated as follows:
3435

3536
[source,js]
3637
--------------------------------------------------
37-
GET /cars/transactions/_search?search_type=count
38+
GET /cars/transactions/_search
3839
{
40+
"size" : 0,
3941
"query" : {
4042
"match_all" : {}
4143
},
@@ -65,7 +67,7 @@ a `match` query):
6567

6668
[source,js]
6769
--------------------------------------------------
68-
GET /cars/transactions/_search <1>
70+
GET /cars/transactions/_search
6971
{
7072
"query" : {
7173
"match" : {
@@ -82,10 +84,9 @@ GET /cars/transactions/_search <1>
8284
}
8385
--------------------------------------------------
8486
// SENSE: 300_Aggregations/40_scope.json
85-
<1> We are omitting `search_type=count` so((("search_type", "count"))) that search hits are returned too.
8687

87-
By omitting the `search_type=count` this time, we can see both the search
88-
results and the aggregation results:
88+
Since we aren't specifying `"size" : 0`, both the search
89+
results and the aggregation results are returned:
8990

9091
[source,js]
9192
--------------------------------------------------
@@ -155,8 +156,9 @@ aggregations inside it as usual:
155156

156157
[source,js]
157158
--------------------------------------------------
158-
GET /cars/transactions/_search?search_type=count
159+
GET /cars/transactions/_search
159160
{
161+
"size" : 0,
160162
"query" : {
161163
"match" : {
162164
"make" : "ford"

0 commit comments

Comments
 (0)