You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linked to elastic/developer-docs-team#314 and
includes fixes for API quickstarts:
Minor rephrasing of sentences
Shortened sentences
Fixes for broken links
Also, removed the redundant migrated content after the main header in
`explore-analyze/query-filter/languages/querydsl.md`
---------
Co-authored-by: Brandon Morelli <[email protected]>
Co-authored-by: István Zoltán Szabó <[email protected]>
Co-authored-by: Liam Thompson <[email protected]>
Copy file name to clipboardExpand all lines: explore-analyze/query-filter/languages/querydsl.md
+4-10Lines changed: 4 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,12 +11,6 @@ products:
11
11
12
12
# Query DSL
13
13
14
-
$$$filter-context$$$
15
-
16
-
$$$query-dsl-allow-expensive-queries$$$
17
-
18
-
$$$relevance-scores$$$
19
-
20
14
## What's Query DSL? [search-analyze-query-dsl]
21
15
22
16
**Query DSL** is a full-featured JSON-style query language that enables complex searching, filtering, and aggregations. It is the original and most powerful query language for {{es}} today.
**Allow expensive queries**: Certain types of queries will generally execute slowly due to the way they are implemented, which can affect the stability of the cluster. Those queries can be categorized as follows:
67
61
68
-
- Queries that need to do linear scans to identify matches:
62
+
- Queries that need to do linear scans to identify matches:
- queries on [numeric](elasticsearch://reference/elasticsearch/mapping-reference/number.md), [date](elasticsearch://reference/elasticsearch/mapping-reference/date.md), [boolean](elasticsearch://reference/elasticsearch/mapping-reference/boolean.md), [ip](elasticsearch://reference/elasticsearch/mapping-reference/ip.md), [geo_point](elasticsearch://reference/elasticsearch/mapping-reference/geo-point.md) or [keyword](elasticsearch://reference/elasticsearch/mapping-reference/keyword.md) fields that are not indexed but have [doc values](elasticsearch://reference/elasticsearch/mapping-reference/doc-values.md) enabled
72
66
73
-
- Queries that have a high up-front cost:
67
+
- Queries that have a high up-front cost:
74
68
75
69
-[`fuzzy` queries](elasticsearch://reference/query-languages/query-dsl/query-dsl-fuzzy-query.md) (except on [`wildcard`](elasticsearch://reference/elasticsearch/mapping-reference/keyword.md#wildcard-field-type) fields)
76
70
-[`regexp` queries](elasticsearch://reference/query-languages/query-dsl/query-dsl-regexp-query.md) (except on [`wildcard`](elasticsearch://reference/elasticsearch/mapping-reference/keyword.md#wildcard-field-type) fields)
77
71
-[`prefix` queries](elasticsearch://reference/query-languages/query-dsl/query-dsl-prefix-query.md) (except on [`wildcard`](elasticsearch://reference/elasticsearch/mapping-reference/keyword.md#wildcard-field-type) fields or those without [`index_prefixes`](elasticsearch://reference/elasticsearch/mapping-reference/index-prefixes.md))
78
72
-[`wildcard` queries](elasticsearch://reference/query-languages/query-dsl/query-dsl-wildcard-query.md) (except on [`wildcard`](elasticsearch://reference/elasticsearch/mapping-reference/keyword.md#wildcard-field-type) fields)
79
73
-[`range` queries](elasticsearch://reference/query-languages/query-dsl/query-dsl-range-query.md) on [`text`](elasticsearch://reference/elasticsearch/mapping-reference/text.md) and [`keyword`](elasticsearch://reference/elasticsearch/mapping-reference/keyword.md) fields
Copy file name to clipboardExpand all lines: solutions/search/elasticsearch-basics-quickstart.md
+53-53Lines changed: 53 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ applies_to:
6
6
# Basics quickstart [getting-started]
7
7
8
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). You’ll learn how to create an index, add data as documents, work with dynamic and explicit mappings, and perform your first basic searches.
9
+
This quickstart provides a hands-on introduction to the fundamental concepts of {{es}}: [indices, documents, and field type mappings](../../manage-data/data-store/index-basics.md). You'll learn how to create an index, add documents, work with dynamic and explicit mappings, and perform your first basic searches.
10
10
11
11
::::{tip}
12
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.
@@ -15,9 +15,7 @@ The code examples in this tutorial are in [Console](../../explore-analyze/query-
15
15
16
16
## Requirements [getting-started-requirements]
17
17
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).
19
-
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):
18
+
You can follow this guide using any {{es}} deployment. If you have a deployment ready, skip ahead to the [first step](#getting-started-index-creation). If not, refer to [choose your deployment type](/deploy-manage/deploy.md#choosing-your-deployment-type) to see all deployment options. To get started quickly, spin up a cluster [locally in Docker](run-elasticsearch-locally.md):
21
19
22
20
```sh
23
21
curl -fsSL https://elastic.co/start-local | sh
@@ -45,8 +43,6 @@ The following response indicates the index was created successfully.
45
43
46
44
::::
47
45
48
-
49
-
50
46
## Step 2: Add data to your index [getting-started-add-documents]
51
47
52
48
::::{tip}
@@ -60,10 +56,10 @@ You add data to {{es}} as JSON objects called documents. {{es}} stores these doc
60
56
61
57
### Add a single document [getting-started-add-single-document]
62
58
63
-
Submit the following indexing request to add a single document to the `books` index.
59
+
Use the following request to add a single document to the `books` index.
64
60
65
-
::::{tip}
66
-
If the index didn’t already exist, this request would automatically create it.
61
+
::::{note}
62
+
If the index doesn't already exist, this request will automatically create it.
67
63
68
64
::::
69
65
@@ -97,25 +93,23 @@ The response includes metadata that {{es}} generates for the document, including
97
93
}
98
94
```
99
95
100
-
1.The `_index` field indicates the index the document was added to.
101
-
2.The `_id` field is the unique identifier for the document.
102
-
3.The `_version` field indicates the version of the document.
103
-
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.
105
-
6.The `total` field indicates the total number of shards for the index.
106
-
7.The `successful` field indicates the number of shards that the indexing operation was executed on.
107
-
8.The `failed` field indicates the number of shards that failed during the indexing operation. *0* indicates no failures.
108
-
9.The `_seq_no` field holds a monotonically increasing number incremented for each indexing operation on a shard.
109
-
10.The `_primary_term` field is a monotonically increasing number incremented each time a primary shard is assigned to a different node.
96
+
1.`_index`: The index the document was added to.
97
+
2.`_id`: The unique identifier for the document.
98
+
3.`_version`: The version of the document.
99
+
4.`result`: The result of the indexing operation.
100
+
5.`_shards`: Information about the number of [shards](../../deploy-manage/distributed-architecture/clusters-nodes-shards.md) that the indexing operation was executed on and the number that succeeded.
101
+
6.`total`: The total number of shards for the index.
102
+
7.`successful`: The number of shards that the indexing operation was performed on.
103
+
8.`failed`: The number of shards that failed during the indexing operation. *0* indicates no failures.
104
+
9.`_seq_no`: A monotonically increasing number incremented for each indexing operation on a shard.
105
+
10.`_primary_term`: A monotonically increasing number incremented each time a primary shard is assigned to a different node.
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).
112
+
Use the [`_bulk` endpoint](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk) to add multiple documents in a single request. Bulk data must be formatted as newline-delimited JSON (NDJSON).
[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
226
234
227
235
228
### Use dynamic mapping [getting-started-dynamic-mapping]
236
229
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.
230
+
When you use dynamic mapping, {{es}} automatically creates mappings for new fields by default. The documents you’ve added so far have used dynamic mapping, because you didn’t specify a mapping while creating the index.
238
231
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.
232
+
To see how dynamic mapping works, add a new document to the `books` index with a field that isn't available in the existing documents.
240
233
241
234
```console
242
235
POST /books/_doc
@@ -251,14 +244,14 @@ POST /books/_doc
251
244
252
245
1. The new field.
253
246
254
-
255
247
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.
256
248
257
249
```console
258
250
GET /books/_mapping
259
251
```
260
-
252
+
The following response displays the mappings that were created by {{es}}.
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).
305
+
Create an index named `my-explicit-mappings-books`and specify the mappings yourself. 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).
313
306
314
307
```console
315
308
PUT /my-explicit-mappings-books
@@ -326,10 +319,10 @@ PUT /my-explicit-mappings-books
326
319
}
327
320
```
328
321
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 won’t be indexed or searchable.
330
-
2. The `properties` object defines the fields and their data types for documents in this index.
331
-
322
+
1.`dynamic`: Disables dynamic mapping for the index. If you don't define fields in the mapping, they'll still be stored in the document's `_source` field, but you can't index or search them.
323
+
2.`properties`: Defines the fields and their corresponding data types.
332
324
325
+
The following response indicates a successful operation.
333
326
::::{dropdown} Example response
334
327
```console-result
335
328
{
@@ -350,14 +343,14 @@ Explicit mappings are defined at index creation, and documents must conform to t
350
343
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
344
352
345
353
-
## Step 4: Search your index[getting-started-search-data]
346
+
## Step 4: Search your data[getting-started-search-data]
354
347
355
348
Indexed documents are available for search in near real-time, using the [`_search` API](querying-for-search.md).
356
349
357
350
358
351
### Search all documents [getting-started-search-all-documents]
359
352
360
-
Run the following command to search the `books` index for all documents:
353
+
Use the following request to search all documents in the `books` index:
361
354
362
355
```console
363
356
GET books/_search
@@ -398,27 +391,25 @@ GET books/_search
398
391
}
399
392
```
400
393
401
-
1.The `took` field indicates the time in milliseconds for {{es}} to execute the search
402
-
2.The `timed_out` field indicates whether the search timed out
403
-
3.The `_shards` field contains information about the number of [shards](/reference/glossary/index.md) that the search was executed on and the number that succeeded
404
-
4.The `hits` object contains the search results
405
-
5.The `total` object provides information about the total number of matching documents
406
-
6.The `max_score` field indicates the highest relevance score among all matching documents
407
-
7.The `_index` field indicates the index the document belongs to
408
-
8.The `_id` field is the document’s unique identifier
409
-
9.The `_score` field indicates the relevance score of the document
410
-
10.The `_source` field contains the original JSON object submitted during indexing
394
+
1.`took`: The time in milliseconds for {{es}} to execute the search
395
+
2.`timed_out`: Indicates if the search timed out
396
+
3.`_shards`: Information about the number of [shards](/reference/glossary/index.md) that the search was performed on and the number that succeeded
397
+
4.`hits`: Has the search results
398
+
5.`total`: Information about the total number of matching documents
399
+
6.`max_score`: The highest relevance score among all matching documents
400
+
7.`_index`: The index the document belongs to
401
+
8.`_id`: The document’s unique identifier
402
+
9.`_score`: The relevance score of the document
403
+
10.`_source`: The original JSON object submitted during indexing
411
404
412
405
413
406
::::
414
407
408
+
### Search using `match` query [getting-started-match-query]
415
409
410
+
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.
416
411
417
-
### `match` query [getting-started-match-query]
418
-
419
-
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.
420
-
421
-
Run the following command to search the `books` index for documents containing `brave` in the `name` field:
412
+
Use the following request to search the `books` index for documents containing `brave` in the `name` field:
422
413
423
414
```console
424
415
GET books/_search
@@ -465,18 +456,18 @@ GET books/_search
465
456
}
466
457
```
467
458
468
-
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.
459
+
1.`max_score`: 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.
469
460
470
461
471
462
::::
472
463
473
464
474
465
475
-
## Step 5: Delete your indices (optional) [getting-started-delete-indices]
466
+
## Step 5: Delete your indices [getting-started-delete-indices]
476
467
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).
468
+
If you want to delete an index to start from scratch at any point, use the [Delete index API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete).
478
469
479
-
For example, run the following command to delete the indices created in this tutorial:
470
+
For example, use the following request to delete the indices created in this tutorial:
Deleting an index permanently deletes its documents, shards, and metadata.
488
479
489
480
::::
481
+
482
+
## Learn more [full-text-filter-tutorial-learn-more]
483
+
484
+
This tutorial introduced the basics of creating indices, adding data and performing basic searches with {{es}}. The following resources will help you understand {{es}} concepts better and dive into the basics of query languages for searching data:
485
+
486
+
*[Fundamentals of Elasticsearch](../../manage-data/data-store.md)
487
+
*[Search and filter with Query DSL](querydsl-full-text-filter-tutorial.md)
0 commit comments