getting-started.asciidoc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. [[getting-started]]
  2. = Getting started with {es}
  3. [partintro]
  4. --
  5. Ready to take {es} for a test drive and see for yourself how you can use the
  6. REST APIs to store, search, and analyze data?
  7. Follow this getting started tutorial to:
  8. . Get an {es} cluster up and running
  9. . Index some sample documents
  10. . Search for documents using the {es} query language
  11. . Analyze the results using bucket and metrics aggregations
  12. Need more context?
  13. Check out the <<elasticsearch-intro,
  14. {es} Introduction>> to learn the lingo and understand the basics of
  15. how {es} works. If you're already familiar with {es} and want to see how it works
  16. with the rest of the stack, you might want to jump to the
  17. {stack-gs}/get-started-elastic-stack.html[Elastic Stack
  18. Tutorial] to see how to set up a system monitoring solution with {es}, {kib},
  19. {beats}, and {ls}.
  20. TIP: The fastest way to get started with {es} is to
  21. https://www.elastic.co/cloud/elasticsearch-service/signup[start a free 14-day
  22. trial of {ess}] in the cloud.
  23. --
  24. [[getting-started-install]]
  25. == Get {es} up and running
  26. To take {es} for a test drive, you can create a
  27. https://www.elastic.co/cloud/elasticsearch-service/signup[hosted deployment] on
  28. the {ess} or set up a multi-node {es} cluster on your own
  29. Linux, macOS, or Windows machine.
  30. [float]
  31. [[run-elasticsearch-hosted]]
  32. === Run {es} on Elastic Cloud
  33. When you create a deployment on the {es} Service, the service provisions
  34. a three-node {es} cluster along with Kibana and APM.
  35. To create a deployment:
  36. . Sign up for a https://www.elastic.co/cloud/elasticsearch-service/signup[free trial]
  37. and verify your email address.
  38. . Set a password for your account.
  39. . Click **Create Deployment**.
  40. Once you've created a deployment, you're ready to <<getting-started-index>>.
  41. [float]
  42. [[run-elasticsearch-local]]
  43. === Run {es} locally on Linux, macOS, or Windows
  44. When you create a deployment on the {ess}, a master node and
  45. two data nodes are provisioned automatically. By installing from the tar or zip
  46. archive, you can start multiple instances of {es} locally to see how a multi-node
  47. cluster behaves.
  48. To run a three-node {es} cluster locally:
  49. . Download the {es} archive for your OS:
  50. +
  51. Linux: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}-linux-x86_64.tar.gz[elasticsearch-{version}-linux-x86_64.tar.gz]
  52. +
  53. ["source","sh",subs="attributes,callouts"]
  54. --------------------------------------------------
  55. curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}-linux-x86_64.tar.gz
  56. --------------------------------------------------
  57. // NOTCONSOLE
  58. +
  59. macOS: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}-darwin-x86_64.tar.gz[elasticsearch-{version}-darwin-x86_64.tar.gz]
  60. +
  61. ["source","sh",subs="attributes,callouts"]
  62. --------------------------------------------------
  63. curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}-darwin-x86_64.tar.gz
  64. --------------------------------------------------
  65. // NOTCONSOLE
  66. +
  67. Windows:
  68. https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}-windows-x86_64.zip[elasticsearch-{version}-windows-x86_64.zip]
  69. . Extract the archive:
  70. +
  71. Linux:
  72. +
  73. ["source","sh",subs="attributes,callouts"]
  74. --------------------------------------------------
  75. tar -xvf elasticsearch-{version}-linux-x86_64.tar.gz
  76. --------------------------------------------------
  77. +
  78. macOS:
  79. +
  80. ["source","sh",subs="attributes,callouts"]
  81. --------------------------------------------------
  82. tar -xvf elasticsearch-{version}-darwin-x86_64.tar.gz
  83. --------------------------------------------------
  84. +
  85. Windows PowerShell:
  86. +
  87. ["source","powershell",subs="attributes,callouts"]
  88. --------------------------------------------------
  89. Expand-Archive elasticsearch-{version}-windows-x86_64.zip
  90. --------------------------------------------------
  91. . Start {es} from the `bin` directory:
  92. +
  93. Linux and macOS:
  94. +
  95. ["source","sh",subs="attributes,callouts"]
  96. --------------------------------------------------
  97. cd elasticsearch-{version}/bin
  98. ./elasticsearch
  99. --------------------------------------------------
  100. +
  101. Windows:
  102. +
  103. ["source","powershell",subs="attributes,callouts"]
  104. --------------------------------------------------
  105. cd elasticsearch-{version}\bin
  106. .\elasticsearch.bat
  107. --------------------------------------------------
  108. +
  109. You now have a single-node {es} cluster up and running!
  110. . Start two more instances of {es} so you can see how a typical multi-node
  111. cluster behaves. You need to specify unique data and log paths
  112. for each node.
  113. +
  114. Linux and macOS:
  115. +
  116. ["source","sh",subs="attributes,callouts"]
  117. --------------------------------------------------
  118. ./elasticsearch -Epath.data=data2 -Epath.logs=log2
  119. ./elasticsearch -Epath.data=data3 -Epath.logs=log3
  120. --------------------------------------------------
  121. +
  122. Windows:
  123. +
  124. ["source","powershell",subs="attributes,callouts"]
  125. --------------------------------------------------
  126. .\elasticsearch.bat -E path.data=data2 -E path.logs=log2
  127. .\elasticsearch.bat -E path.data=data3 -E path.logs=log3
  128. --------------------------------------------------
  129. +
  130. The additional nodes are assigned unique IDs. Because you're running all three
  131. nodes locally, they automatically join the cluster with the first node.
  132. . Use the cat health API to verify that your three-node cluster is up running.
  133. The cat APIs return information about your cluster and indices in a
  134. format that's easier to read than raw JSON.
  135. +
  136. You can interact directly with your cluster by submitting HTTP requests to
  137. the {es} REST API. Most of the examples in this guide enable you to copy the
  138. appropriate cURL command and submit the request to your local {es} instance from
  139. the command line. If you have Kibana installed and running, you can also
  140. open Kibana and submit requests through the Dev Console.
  141. +
  142. TIP: You'll want to check out the
  143. https://www.elastic.co/guide/en/elasticsearch/client/index.html[{es} language
  144. clients] when you're ready to start using {es} in your own applications.
  145. +
  146. [source,console]
  147. --------------------------------------------------
  148. GET /_cat/health?v
  149. --------------------------------------------------
  150. +
  151. The response should indicate that the status of the `elasticsearch` cluster
  152. is `green` and it has three nodes:
  153. +
  154. [source,txt]
  155. --------------------------------------------------
  156. epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
  157. 1565052807 00:53:27 elasticsearch green 3 3 6 3 0 0 0 0 - 100.0%
  158. --------------------------------------------------
  159. // TESTRESPONSE[s/1565052807 00:53:27 elasticsearch/\\d+ \\d+:\\d+:\\d+ integTest/]
  160. // TESTRESPONSE[s/3 3 6 3/\\d+ \\d+ \\d+ \\d+/]
  161. // TESTRESPONSE[s/0 0 -/0 \\d+ (-|\\d+(micros|ms|s))/]
  162. // TESTRESPONSE[non_json]
  163. +
  164. NOTE: The cluster status will remain yellow if you are only running a single
  165. instance of {es}. A single node cluster is fully functional, but data
  166. cannot be replicated to another node to provide resiliency. Replica shards must
  167. be available for the cluster status to be green. If the cluster status is red,
  168. some data is unavailable.
  169. [float]
  170. [[gs-other-install]]
  171. === Other installation options
  172. Installing {es} from an archive file enables you to easily install and run
  173. multiple instances locally so you can try things out. To run a single instance,
  174. you can run {es} in a Docker container, install {es} using the DEB or RPM
  175. packages on Linux, install using Homebrew on macOS, or install using the MSI
  176. package installer on Windows. See <<install-elasticsearch>> for more information.
  177. [[getting-started-index]]
  178. == Index some documents
  179. Once you have a cluster up and running, you're ready to index some data.
  180. There are a variety of ingest options for {es}, but in the end they all
  181. do the same thing: put JSON documents into an {es} index.
  182. You can do this directly with a simple PUT request that specifies
  183. the index you want to add the document, a unique document ID, and one or more
  184. `"field": "value"` pairs in the request body:
  185. [source,console]
  186. --------------------------------------------------
  187. PUT /customer/_doc/1
  188. {
  189. "name": "John Doe"
  190. }
  191. --------------------------------------------------
  192. This request automatically creates the `customer` index if it doesn't already
  193. exist, adds a new document that has an ID of `1`, and stores and
  194. indexes the `name` field.
  195. Since this is a new document, the response shows that the result of the
  196. operation was that version 1 of the document was created:
  197. [source,console-result]
  198. --------------------------------------------------
  199. {
  200. "_index" : "customer",
  201. "_id" : "1",
  202. "_version" : 1,
  203. "result" : "created",
  204. "_shards" : {
  205. "total" : 2,
  206. "successful" : 2,
  207. "failed" : 0
  208. },
  209. "_seq_no" : 26,
  210. "_primary_term" : 4
  211. }
  212. --------------------------------------------------
  213. // TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/]
  214. // TESTRESPONSE[s/"successful" : \d+/"successful" : $body._shards.successful/]
  215. // TESTRESPONSE[s/"_primary_term" : \d+/"_primary_term" : $body._primary_term/]
  216. The new document is available immediately from any node in the cluster.
  217. You can retrieve it with a GET request that specifies its document ID:
  218. [source,console]
  219. --------------------------------------------------
  220. GET /customer/_doc/1
  221. --------------------------------------------------
  222. // TEST[continued]
  223. The response indicates that a document with the specified ID was found
  224. and shows the original source fields that were indexed.
  225. [source,console-result]
  226. --------------------------------------------------
  227. {
  228. "_index" : "customer",
  229. "_id" : "1",
  230. "_version" : 1,
  231. "_seq_no" : 26,
  232. "_primary_term" : 4,
  233. "found" : true,
  234. "_source" : {
  235. "name": "John Doe"
  236. }
  237. }
  238. --------------------------------------------------
  239. // TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ ]
  240. // TESTRESPONSE[s/"_primary_term" : \d+/"_primary_term" : $body._primary_term/]
  241. [float]
  242. [[getting-started-batch-processing]]
  243. === Indexing documents in bulk
  244. If you have a lot of documents to index, you can submit them in batches with
  245. the {ref}/docs-bulk.html[bulk API]. Using bulk to batch document
  246. operations is significantly faster than submitting requests individually as it minimizes network roundtrips.
  247. The optimal batch size depends on a number of factors: the document size and complexity, the indexing and search load, and the resources available to your cluster. A good place to start is with batches of 1,000 to 5,000 documents
  248. and a total payload between 5MB and 15MB. From there, you can experiment
  249. to find the sweet spot.
  250. To get some data into {es} that you can start searching and analyzing:
  251. . Download the https://github.com/elastic/elasticsearch/blob/master/docs/src/test/resources/accounts.json?raw=true[`accounts.json`] sample data set. The documents in this randomly-generated data set represent user accounts with the following information:
  252. +
  253. [source,js]
  254. --------------------------------------------------
  255. {
  256. "account_number": 0,
  257. "balance": 16623,
  258. "firstname": "Bradshaw",
  259. "lastname": "Mckenzie",
  260. "age": 29,
  261. "gender": "F",
  262. "address": "244 Columbus Place",
  263. "employer": "Euron",
  264. "email": "bradshawmckenzie@euron.com",
  265. "city": "Hobucken",
  266. "state": "CO"
  267. }
  268. --------------------------------------------------
  269. // NOTCONSOLE
  270. . Index the account data into the `bank` index with the following `_bulk` request:
  271. +
  272. [source,sh]
  273. --------------------------------------------------
  274. curl -H "Content-Type: application/json" -XPOST "localhost:9200/bank/_bulk?pretty&refresh" --data-binary "@accounts.json"
  275. curl "localhost:9200/_cat/indices?v"
  276. --------------------------------------------------
  277. // NOTCONSOLE
  278. +
  279. ////
  280. This replicates the above in a document-testing friendly way but isn't visible
  281. in the docs:
  282. +
  283. [source,console]
  284. --------------------------------------------------
  285. GET /_cat/indices?v
  286. --------------------------------------------------
  287. // TEST[setup:bank]
  288. ////
  289. +
  290. The response indicates that 1,000 documents were indexed successfully.
  291. +
  292. [source,txt]
  293. --------------------------------------------------
  294. health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
  295. yellow open bank l7sSYV2cQXmu6_4rJWVIww 5 1 1000 0 128.6kb 128.6kb
  296. --------------------------------------------------
  297. // TESTRESPONSE[s/128.6kb/\\d+(\\.\\d+)?[mk]?b/]
  298. // TESTRESPONSE[s/l7sSYV2cQXmu6_4rJWVIww/.+/ non_json]
  299. [[getting-started-search]]
  300. == Start searching
  301. Once you have ingested some data into an {es} index, you can search it
  302. by sending requests to the `_search` endpoint. To access the full suite of
  303. search capabilities, you use the {es} Query DSL to specify the
  304. search criteria in the request body. You specify the name of the index you
  305. want to search in the request URI.
  306. For example, the following request retrieves all documents in the `bank`
  307. index sorted by account number:
  308. [source,console]
  309. --------------------------------------------------
  310. GET /bank/_search
  311. {
  312. "query": { "match_all": {} },
  313. "sort": [
  314. { "account_number": "asc" }
  315. ]
  316. }
  317. --------------------------------------------------
  318. // TEST[continued]
  319. By default, the `hits` section of the response includes the first 10 documents
  320. that match the search criteria:
  321. [source,console-result]
  322. --------------------------------------------------
  323. {
  324. "took" : 63,
  325. "timed_out" : false,
  326. "_shards" : {
  327. "total" : 5,
  328. "successful" : 5,
  329. "skipped" : 0,
  330. "failed" : 0
  331. },
  332. "hits" : {
  333. "total" : {
  334. "value": 1000,
  335. "relation": "eq"
  336. },
  337. "max_score" : null,
  338. "hits" : [ {
  339. "_index" : "bank",
  340. "_id" : "0",
  341. "sort": [0],
  342. "_score" : null,
  343. "_source" : {"account_number":0,"balance":16623,"firstname":"Bradshaw","lastname":"Mckenzie","age":29,"gender":"F","address":"244 Columbus Place","employer":"Euron","email":"bradshawmckenzie@euron.com","city":"Hobucken","state":"CO"}
  344. }, {
  345. "_index" : "bank",
  346. "_id" : "1",
  347. "sort": [1],
  348. "_score" : null,
  349. "_source" : {"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
  350. }, ...
  351. ]
  352. }
  353. }
  354. --------------------------------------------------
  355. // TESTRESPONSE[s/"took" : 63/"took" : $body.took/]
  356. // TESTRESPONSE[s/\.\.\./$body.hits.hits.2, $body.hits.hits.3, $body.hits.hits.4, $body.hits.hits.5, $body.hits.hits.6, $body.hits.hits.7, $body.hits.hits.8, $body.hits.hits.9/]
  357. The response also provides the following information about the search request:
  358. * `took` – how long it took {es} to run the query, in milliseconds
  359. * `timed_out` – whether or not the search request timed out
  360. * `_shards` – how many shards were searched and a breakdown of how many shards
  361. succeeded, failed, or were skipped.
  362. * `max_score` – the score of the most relevant document found
  363. * `hits.total.value` - how many matching documents were found
  364. * `hits.sort` - the document's sort position (when not sorting by relevance score)
  365. * `hits._score` - the document's relevance score (not applicable when using `match_all`)
  366. Each search request is self-contained: {es} does not maintain any
  367. state information across requests. To page through the search hits, specify
  368. the `from` and `size` parameters in your request.
  369. For example, the following request gets hits 10 through 19:
  370. [source,console]
  371. --------------------------------------------------
  372. GET /bank/_search
  373. {
  374. "query": { "match_all": {} },
  375. "sort": [
  376. { "account_number": "asc" }
  377. ],
  378. "from": 10,
  379. "size": 10
  380. }
  381. --------------------------------------------------
  382. // TEST[continued]
  383. Now that you've seen how to submit a basic search request, you can start to
  384. construct queries that are a bit more interesting than `match_all`.
  385. To search for specific terms within a field, you can use a `match` query.
  386. For example, the following request searches the `address` field to find
  387. customers whose addresses contain `mill` or `lane`:
  388. [source,console]
  389. --------------------------------------------------
  390. GET /bank/_search
  391. {
  392. "query": { "match": { "address": "mill lane" } }
  393. }
  394. --------------------------------------------------
  395. // TEST[continued]
  396. To perform a phrase search rather than matching individual terms, you use
  397. `match_phrase` instead of `match`. For example, the following request only
  398. matches addresses that contain the phrase `mill lane`:
  399. [source,console]
  400. --------------------------------------------------
  401. GET /bank/_search
  402. {
  403. "query": { "match_phrase": { "address": "mill lane" } }
  404. }
  405. --------------------------------------------------
  406. // TEST[continued]
  407. To construct more complex queries, you can use a `bool` query to combine
  408. multiple query criteria. You can designate criteria as required (must match),
  409. desirable (should match), or undesirable (must not match).
  410. For example, the following request searches the `bank` index for accounts that
  411. belong to customers who are 40 years old, but excludes anyone who lives in
  412. Idaho (ID):
  413. [source,console]
  414. --------------------------------------------------
  415. GET /bank/_search
  416. {
  417. "query": {
  418. "bool": {
  419. "must": [
  420. { "match": { "age": "40" } }
  421. ],
  422. "must_not": [
  423. { "match": { "state": "ID" } }
  424. ]
  425. }
  426. }
  427. }
  428. --------------------------------------------------
  429. // TEST[continued]
  430. Each `must`, `should`, and `must_not` element in a Boolean query is referred
  431. to as a query clause. How well a document meets the criteria in each `must` or
  432. `should` clause contributes to the document's _relevance score_. The higher the
  433. score, the better the document matches your search criteria. By default, {es}
  434. returns documents ranked by these relevance scores.
  435. The criteria in a `must_not` clause is treated as a _filter_. It affects whether
  436. or not the document is included in the results, but does not contribute to
  437. how documents are scored. You can also explicitly specify arbitrary filters to
  438. include or exclude documents based on structured data.
  439. For example, the following request uses a range filter to limit the results to
  440. accounts with a balance between $20,000 and $30,000 (inclusive).
  441. [source,console]
  442. --------------------------------------------------
  443. GET /bank/_search
  444. {
  445. "query": {
  446. "bool": {
  447. "must": { "match_all": {} },
  448. "filter": {
  449. "range": {
  450. "balance": {
  451. "gte": 20000,
  452. "lte": 30000
  453. }
  454. }
  455. }
  456. }
  457. }
  458. }
  459. --------------------------------------------------
  460. // TEST[continued]
  461. [[getting-started-aggregations]]
  462. == Analyze results with aggregations
  463. {es} aggregations enable you to get meta-information about your search results
  464. and answer questions like, "How many account holders are in Texas?" or
  465. "What's the average balance of accounts in Tennessee?" You can search
  466. documents, filter hits, and use aggregations to analyze the results all in one
  467. request.
  468. For example, the following request uses a `terms` aggregation to group
  469. all of the accounts in the `bank` index by state, and returns the ten states
  470. with the most accounts in descending order:
  471. [source,console]
  472. --------------------------------------------------
  473. GET /bank/_search
  474. {
  475. "size": 0,
  476. "aggs": {
  477. "group_by_state": {
  478. "terms": {
  479. "field": "state.keyword"
  480. }
  481. }
  482. }
  483. }
  484. --------------------------------------------------
  485. // TEST[continued]
  486. The `buckets` in the response are the values of the `state` field. The
  487. `doc_count` shows the number of accounts in each state. For example, you
  488. can see that there are 27 accounts in `ID` (Idaho). Because the request
  489. set `size=0`, the response only contains the aggregation results.
  490. [source,console-result]
  491. --------------------------------------------------
  492. {
  493. "took": 29,
  494. "timed_out": false,
  495. "_shards": {
  496. "total": 5,
  497. "successful": 5,
  498. "skipped" : 0,
  499. "failed": 0
  500. },
  501. "hits" : {
  502. "total" : {
  503. "value": 1000,
  504. "relation": "eq"
  505. },
  506. "max_score" : null,
  507. "hits" : [ ]
  508. },
  509. "aggregations" : {
  510. "group_by_state" : {
  511. "doc_count_error_upper_bound": 20,
  512. "sum_other_doc_count": 770,
  513. "buckets" : [ {
  514. "key" : "ID",
  515. "doc_count" : 27
  516. }, {
  517. "key" : "TX",
  518. "doc_count" : 27
  519. }, {
  520. "key" : "AL",
  521. "doc_count" : 25
  522. }, {
  523. "key" : "MD",
  524. "doc_count" : 25
  525. }, {
  526. "key" : "TN",
  527. "doc_count" : 23
  528. }, {
  529. "key" : "MA",
  530. "doc_count" : 21
  531. }, {
  532. "key" : "NC",
  533. "doc_count" : 21
  534. }, {
  535. "key" : "ND",
  536. "doc_count" : 21
  537. }, {
  538. "key" : "ME",
  539. "doc_count" : 20
  540. }, {
  541. "key" : "MO",
  542. "doc_count" : 20
  543. } ]
  544. }
  545. }
  546. }
  547. --------------------------------------------------
  548. // TESTRESPONSE[s/"took": 29/"took": $body.took/]
  549. You can combine aggregations to build more complex summaries of your data. For
  550. example, the following request nests an `avg` aggregation within the previous
  551. `group_by_state` aggregation to calculate the average account balances for
  552. each state.
  553. [source,console]
  554. --------------------------------------------------
  555. GET /bank/_search
  556. {
  557. "size": 0,
  558. "aggs": {
  559. "group_by_state": {
  560. "terms": {
  561. "field": "state.keyword"
  562. },
  563. "aggs": {
  564. "average_balance": {
  565. "avg": {
  566. "field": "balance"
  567. }
  568. }
  569. }
  570. }
  571. }
  572. }
  573. --------------------------------------------------
  574. // TEST[continued]
  575. Instead of sorting the results by count, you could sort using the result of
  576. the nested aggregation by specifying the order within the `terms` aggregation:
  577. [source,console]
  578. --------------------------------------------------
  579. GET /bank/_search
  580. {
  581. "size": 0,
  582. "aggs": {
  583. "group_by_state": {
  584. "terms": {
  585. "field": "state.keyword",
  586. "order": {
  587. "average_balance": "desc"
  588. }
  589. },
  590. "aggs": {
  591. "average_balance": {
  592. "avg": {
  593. "field": "balance"
  594. }
  595. }
  596. }
  597. }
  598. }
  599. }
  600. --------------------------------------------------
  601. // TEST[continued]
  602. In addition to basic bucketing and metrics aggregations like these, {es}
  603. provides specialized aggregations for operating on multiple fields and
  604. analyzing particular types of data such as dates, IP addresses, and geo
  605. data. You can also feed the results of individual aggregations into pipeline
  606. aggregations for further analysis.
  607. The core analysis capabilities provided by aggregations enable advanced
  608. features such as using machine learning to detect anomalies.
  609. [[getting-started-next-steps]]
  610. == Where to go from here
  611. Now that you've set up a cluster, indexed some documents, and run some
  612. searches and aggregations, you might want to:
  613. * {stack-gs}/get-started-elastic-stack.html#install-kibana[Dive in to the Elastic
  614. Stack Tutorial] to install Kibana, Logstash, and Beats and
  615. set up a basic system monitoring solution.
  616. * {kibana-ref}/add-sample-data.html[Load one of the sample data sets into Kibana]
  617. to see how you can use {es} and Kibana together to visualize your data.
  618. * Try out one of the Elastic search solutions:
  619. ** https://swiftype.com/documentation/site-search/crawler-quick-start[Site Search]
  620. ** https://swiftype.com/documentation/app-search/getting-started[App Search]
  621. ** https://swiftype.com/documentation/enterprise-search/getting-started[Enterprise Search]