Skip to content

Commit bcfdb0c

Browse files
committed
Edit style
1 parent 8c12091 commit bcfdb0c

File tree

2 files changed

+86
-91
lines changed

2 files changed

+86
-91
lines changed

solutions/search/get-started/elasticsearch-basics-quickstart.md

Lines changed: 85 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@ applies_to:
33
stack:
44
serverless:
55
---
6-
# Basics quickstart [getting-started]
6+
# Index and search basics
77

8-
9-
This quick start guide is a hands-on introduction to the fundamental concepts of Elasticsearch: [indices, documents, and field type mappings](../../../manage-data/data-store/index-basics.md). Youll learn how to create an index, add data as documents, work with dynamic and explicit mappings, and perform your first basic searches.
8+
This quick start guide is a hands-on introduction to the fundamental concepts of Elasticsearch: indices, documents, and field type mappings.
9+
You'll learn how to create an index, add data as documents, work with dynamic and explicit mappings, and perform your first basic searches.
1010

1111
::::{tip}
12-
The code examples in this tutorial are in [Console](../../../explore-analyze/query-filter/tools/console.md) syntax by default. You can [convert into other programming languages](../../../explore-analyze/query-filter/tools/console.md#import-export-console-requests) in the Console UI.
12+
The code examples are in [Console](/explore-analyze/query-filter/tools/console.md) syntax by default. You can [convert into other programming languages](/explore-analyze/query-filter/tools/console.md#import-export-console-requests) in the Console UI.
1313

1414
::::
1515

1616
## Requirements [getting-started-requirements]
1717

18-
You can follow this guide using any {{es}} deployment. If you already have a deployment up and running, you can skip ahead to the [first step](#getting-started-index-creation).
18+
You can follow this guide using any {{es}} deployment.
19+
If you already have a deployment up and running, refer to [choose your deployment type](/deploy-manage/deploy.md#choosing-your-deployment-type) for your options.
20+
To get started quickly, you can spin up a cluster [locally in Docker](/solutions/search/get-started.md).
1921

20-
If not, refer to [choose your deployment type](/deploy-manage/deploy.md#choosing-your-deployment-type) for your options. To get started quickly, you can spin up a cluster [locally in Docker](../get-started.md):
22+
## Add data to {{es}}
2123

22-
```sh
23-
curl -fsSL https://elastic.co/start-local | sh
24-
```
24+
::::{tip}
25+
This quick start uses {{es}} APIs, but there are many other ways to [add data to {{es}}](/solutions/search/ingest-for-search.md).
26+
::::
2527

28+
You add data to {{es}} as JSON objects called documents.
29+
{{es}} stores these documents in searchable indices.
2630

27-
## Step 1: Create an index [getting-started-index-creation]
31+
:::::{stepper}
32+
::::{step} Create an index
2833

2934
Create a new index named `books`:
3035

@@ -34,7 +39,8 @@ PUT /books
3439

3540
The following response indicates the index was created successfully.
3641

37-
::::{dropdown} Example response
42+
:::{dropdown} Example response
43+
3844
```console-result
3945
{
4046
"acknowledged": true,
@@ -43,30 +49,11 @@ The following response indicates the index was created successfully.
4349
}
4450
```
4551

52+
:::
4653
::::
54+
::::{step} Add a single document
4755

48-
49-
50-
## Step 2: Add data to your index [getting-started-add-documents]
51-
52-
::::{tip}
53-
This tutorial uses {{es}} APIs, but there are many other ways to [add data to {{es}}](../ingest-for-search.md).
54-
55-
::::
56-
57-
58-
You add data to {{es}} as JSON objects called documents. {{es}} stores these documents in searchable indices.
59-
60-
61-
### Add a single document [getting-started-add-single-document]
62-
63-
Submit the following indexing request to add a single document to the `books` index.
64-
65-
::::{tip}
66-
If the index didn’t already exist, this request would automatically create it.
67-
68-
::::
69-
56+
Submit the following indexing request to add a single document to the `books` index:
7057

7158
```console
7259
POST books/_doc
@@ -78,9 +65,14 @@ POST books/_doc
7865
}
7966
```
8067

68+
:::{tip}
69+
If the index didn't already exist, this request would automatically create it.
70+
:::
71+
8172
The response includes metadata that {{es}} generates for the document, including a unique `_id` for the document within the index.
8273

83-
::::{dropdown} Example response
74+
:::{dropdown} Example response
75+
8476
```console-result
8577
{
8678
"_index": "books", <1>
@@ -101,21 +93,19 @@ The response includes metadata that {{es}} generates for the document, including
10193
2. The `_id` field is the unique identifier for the document.
10294
3. The `_version` field indicates the version of the document.
10395
4. The `result` field indicates the result of the indexing operation.
104-
5. The `_shards` field contains information about the number of [shards](../../../deploy-manage/index.md) that the indexing operation was executed on and the number that succeeded.
96+
5. The `_shards` field contains information about the number of [shards](/deploy-manage/index.md) that the indexing operation was executed on and the number that succeeded.
10597
6. The `total` field indicates the total number of shards for the index.
10698
7. The `successful` field indicates the number of shards that the indexing operation was executed on.
10799
8. The `failed` field indicates the number of shards that failed during the indexing operation. *0* indicates no failures.
108100
9. The `_seq_no` field holds a monotonically increasing number incremented for each indexing operation on a shard.
109101
10. The `_primary_term` field is a monotonically increasing number incremented each time a primary shard is assigned to a different node.
110102

111-
103+
:::
112104
::::
105+
::::{step} Add multiple documents
113106

114-
115-
116-
### Add multiple documents [getting-started-add-multiple-documents]
117-
118-
Use the [`_bulk` endpoint](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk) to add multiple documents in one request. Bulk data must be formatted as newline-delimited JSON (NDJSON).
107+
Use the [`_bulk` endpoint]({{es-apis}}operation/operation-bulk) to add multiple documents in one request.
108+
Bulk data must be formatted as newline-delimited JSON (NDJSON).
119109

120110
```console
121111
POST /_bulk
@@ -133,7 +123,8 @@ POST /_bulk
133123

134124
You should receive a response indicating there were no errors.
135125

136-
::::{dropdown} Example response
126+
:::{dropdown} Example response
127+
137128
```console-result
138129
{
139130
"errors": false,
@@ -223,20 +214,15 @@ You should receive a response indicating there were no errors.
223214
}
224215
```
225216

217+
:::
226218
::::
219+
::::{step} Use dynamic mapping
227220

221+
[Mappings](/manage-data/data-store/index-basics.md#elasticsearch-intro-documents-fields-mappings) define how data is stored and indexed in {{es}}, like a schema in a relational database.
228222

229-
230-
## Step 3: Define mappings and data types [getting-started-mappings-and-data-types]
231-
232-
[Mappings](../../../manage-data/data-store/index-basics.md#elasticsearch-intro-documents-fields-mappings) define how data is stored and indexed in {{es}}, like a schema in a relational database.
233-
234-
235-
### Use dynamic mapping [getting-started-dynamic-mapping]
236-
237-
When using dynamic mapping, {{es}} automatically creates mappings for new fields by default. The documents we’ve added so far have used dynamic mapping, because we didn’t specify a mapping when creating the index.
238-
239-
To see how dynamic mapping works, add a new document to the `books` index with a field that doesn’t appear in the existing documents.
223+
If you use dynamic mapping, {{es}} automatically creates mappings for new fields.
224+
The documents we've added so far have used dynamic mapping, because we didn't specify a mapping when creating the index.
225+
To see how dynamic mapping works, add a new document to the `books` index with a field that doesn't appear in the existing documents:
240226

241227
```console
242228
POST /books/_doc
@@ -251,14 +237,15 @@ POST /books/_doc
251237

252238
1. The new field.
253239

254-
255-
View the mapping for the `books` index with the [Get mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-mapping). The new field `language` has been added to the mapping with a `text` data type.
240+
View the mapping for the `books` index with the [get mapping API]({{es-apis}}operation/operation-indices-get-mapping).
241+
The new field `language` has been added to the mapping with a `text` data type.
256242

257243
```console
258244
GET /books/_mapping
259245
```
260246

261-
::::{dropdown} Example response
247+
:::{dropdown} Example response
248+
262249
```console-result
263250
{
264251
"books": {
@@ -303,13 +290,11 @@ GET /books/_mapping
303290
}
304291
```
305292

293+
:::
306294
::::
295+
::::{step} Define explicit mapping
307296

308-
309-
310-
### Define explicit mapping [getting-started-explicit-mapping]
311-
312-
Create an index named `my-explicit-mappings-books` with explicit mappings. Pass each field’s properties as a JSON object. This object should contain the [field data type](elasticsearch://reference/elasticsearch/mapping-reference/field-data-types.md) and any additional [mapping parameters](elasticsearch://reference/elasticsearch/mapping-reference/mapping-parameters.md).
297+
Create an index named `my-explicit-mappings-books` with explicit mappings. Pass each field's properties as a JSON object. This object should contain the [field data type](elasticsearch://reference/elasticsearch/mapping-reference/field-data-types.md) and any additional [mapping parameters](elasticsearch://reference/elasticsearch/mapping-reference/mapping-parameters.md).
313298

314299
```console
315300
PUT /my-explicit-mappings-books
@@ -326,11 +311,11 @@ PUT /my-explicit-mappings-books
326311
}
327312
```
328313

329-
1. Disables dynamic mapping for the index. Fields not defined in the mapping will still be stored in the document's `_source` field, but they wont be indexed or searchable.
314+
1. Disables dynamic mapping for the index. Fields not defined in the mapping will still be stored in the document's `_source` field, but they won't be indexed or searchable.
330315
2. The `properties` object defines the fields and their data types for documents in this index.
331316

317+
:::{dropdown} Example response
332318

333-
::::{dropdown} Example response
334319
```console-result
335320
{
336321
"acknowledged": true,
@@ -339,31 +324,29 @@ PUT /my-explicit-mappings-books
339324
}
340325
```
341326

342-
::::
343-
344-
345-
346-
### Combine dynamic and explicit mappings [getting-started-combined-mapping]
347-
348-
Explicit mappings are defined at index creation, and documents must conform to these mappings. You can also use the [Update mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping). When an index has the `dynamic` flag set to `true`, you can add new fields to documents without updating the mapping.
349-
350-
This allows you to combine explicit and dynamic mappings. Learn more about [managing and updating mappings](../../../manage-data/data-store/mapping.md#mapping-manage-update).
351-
327+
:::
352328

353-
## Step 4: Search your index [getting-started-search-data]
329+
Explicit mappings are defined at index creation and documents must conform to these mappings. You can also use the [update mapping API]({{es-apis}}operation/operation-indices-put-mapping) to change the mappings.
330+
When an index has the `dynamic` flag set to `true`, you can add new fields to documents without updating the mapping.
331+
This allows you to combine explicit and dynamic mappings. Learn more about [managing and updating mappings](/manage-data/data-store/mapping.md#mapping-manage-update).
332+
::::
333+
:::::
354334

355-
Indexed documents are available for search in near real-time, using the [`_search` API](../querying-for-search.md).
335+
## Search your index [getting-started-search-data]
356336

337+
Indexed documents are available for search in near real-time, using the [`_search` API](/solutions/search/querying-for-search.md).
357338

358-
### Search all documents [getting-started-search-all-documents]
339+
:::::{stepper}
340+
::::{step} Search all documents
359341

360342
Run the following command to search the `books` index for all documents:
361343

362344
```console
363345
GET books/_search
364346
```
365347

366-
::::{dropdown} Example response
348+
:::{dropdown} Example response
349+
367350
```console-result
368351
{
369352
"took": 2, <1>
@@ -405,16 +388,13 @@ GET books/_search
405388
5. The `total` object provides information about the total number of matching documents
406389
6. The `max_score` field indicates the highest relevance score among all matching documents
407390
7. The `_index` field indicates the index the document belongs to
408-
8. The `_id` field is the documents unique identifier
391+
8. The `_id` field is the document's unique identifier
409392
9. The `_score` field indicates the relevance score of the document
410393
10. The `_source` field contains the original JSON object submitted during indexing
411394

412-
395+
:::
413396
::::
414-
415-
416-
417-
### `match` query [getting-started-match-query]
397+
::::{step} Try a match query
418398

419399
You can use the [`match` query](elasticsearch://reference/query-languages/query-dsl/query-dsl-match-query.md) to search for documents that contain a specific value in a specific field. This is the standard query for full-text searches.
420400

@@ -431,7 +411,12 @@ GET books/_search
431411
}
432412
```
433413

434-
::::{dropdown} Example response
414+
:::{tip}
415+
This example uses [Query DSL](/explore-analyze/query-filter/languages/querydsl.md), which is the primary query language for {{es}}.
416+
:::
417+
418+
:::{dropdown} Example response
419+
435420
```console-result
436421
{
437422
"took": 9,
@@ -467,16 +452,16 @@ GET books/_search
467452

468453
1. The `max_score` is the score of the highest-scoring document in the results. In this case, there is only one matching document, so the `max_score` is the score of that document.
469454

470-
455+
:::
471456
::::
457+
:::::
472458

459+
## Delete your indices [getting-started-delete-indices]
473460

461+
When following along with examples, you might want to delete an index to start from scratch.
462+
You can delete indices using the [delete index API]({{es-apis}}operation/operation-indices-delete).
474463

475-
## Step 5: Delete your indices (optional) [getting-started-delete-indices]
476-
477-
When following along with examples, you might want to delete an index to start from scratch. You can delete indices using the [Delete index API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete).
478-
479-
For example, run the following command to delete the indices created in this tutorial:
464+
For example, run the following command to delete the indices created in this quick start:
480465

481466
```console
482467
DELETE /books
@@ -485,5 +470,14 @@ DELETE /my-explicit-mappings-books
485470

486471
::::{warning}
487472
Deleting an index permanently deletes its documents, shards, and metadata.
488-
489473
::::
474+
475+
## Next books
476+
477+
This quick start guide introduced fundamental {{es}} concepts.
478+
To try out similar steps from the {{es}} Python client, go to [](/solutions/search/get-started/keyword-search-python.md).
479+
To dive into the details, refer to the following resources:
480+
481+
* [](/manage-data/data-store/index-basics.md)
482+
* [REST APIs](elasticsearch://reference/elasticsearch/rest-apis/index.md)
483+
* [](/explore-analyze/query-filter/languages.md)

solutions/search/get-started/quickstarts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Each quickstart provides:
1515

1616
Follow the steps in these guides to get started quickly:
1717

18+
- [](/solutions/search/get-started/elasticsearch-basics-quickstart.md)
1819
- [](/solutions/search/get-started/keyword-search-python.md)
1920
- [](/solutions/search/get-started/semantic-search.md)
2021
- [](/solutions/search/vector/bring-own-vectors.md)

0 commit comments

Comments
 (0)