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
Copy file name to clipboardExpand all lines: docs/reference/query-languages/query-dsl/full-text-filter-tutorial.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,29 +11,27 @@ products:
11
11
12
12
# Get started with Query DSL search and filters [full-text-filter-tutorial]
13
13
14
-
This is a hands-on introduction to the basics of [full-text search](docs-content://solutions/search/full-text.md) with {{es}}, also known as *lexical search*, using the [`_search` API]({{es-apis}}operation/operation-search) and Query DSL.
15
-
You'll also learn how to filter data to narrow down search results based on exact criteria.
14
+
This is a hands-on introduction to the basics of full-text search with {{es}}, also known as *lexical search*, using the `_search` API and Query DSL.
16
15
17
-
In this quickstart, you'll implement a search function for a cooking blog. The blog contains recipes with various attributes including textual content, categorical data, and numerical ratings.
18
-
19
-
The goal is to create search queries that enable users to:
16
+
You'll implement a search function for a cooking blog that contains recipes with textual content, categorical data, and numerical ratings.
17
+
You'll apply filters to narrow down search results and combine multiple search criteria.
18
+
For example, in this scenario you might want to:
20
19
21
20
* Find recipes based on preferred or avoided ingredients
22
21
* Explore dishes that meet specific dietary needs
23
22
* Find top-rated recipes in specific categories
24
23
* Find the latest recipes from favorite authors
25
24
26
-
To achieve these goals, you'll use different Elasticsearch queries to perform full-text search, apply filters, and combine multiple search criteria.
25
+
::::{tip}
26
+
The code examples are in [Console](docs-content://explore-analyze/query-filter/tools/console.md) syntax by default.
27
+
You can [convert into other programming languages](docs-content://explore-analyze/query-filter/tools/console.md#import-export-console-requests) in the Console UI.
You'll need a running {{es}} cluster, together with {{kib}} to use the Dev Tools API Console. Refer to [choose your deployment type](docs-content://deploy-manage/deploy.md#choosing-your-deployment-type) for deployment options.
31
-
32
-
Want to get started quickly? Run the following command in your terminal to set up a [single-node local cluster in Docker](docs-content://solutions/search/run-elasticsearch-locally.md):
33
-
34
-
```sh
35
-
curl -fsSL https://elastic.co/start-local | sh
36
-
```
32
+
You can follow these steps in any {{es}} deployment.
33
+
To see all deployment options, refer to [Choosing your deployment type](docs-content://deploy-manage/deploy.md#choosing-your-deployment-type).
34
+
To get started quickly, set up a [single-node local cluster in Docker](docs-content://solutions/search/run-elasticsearch-locally.md).
37
35
38
36
## Create an index [full-text-filter-tutorial-create-index]
39
37
@@ -200,7 +198,7 @@ At search time, {{es}} defaults to the analyzer defined in the field mapping. In
200
198
```
201
199
202
200
1.`hits`: Contains the total number of matching documents and their relation to the total.
203
-
2.`max_score`: The highest relevance score among all matching documents. In this example, we only have one matching document.
201
+
2.`max_score`: The highest relevance score among all matching documents. In this example, there is only have one matching document.
204
202
3.`_score`: The relevance score for a specific document, indicating how well it matches the query. Higher scores indicate better matches. In this example the `max_score` is the same as the `_score`, as there is only one matching document.
205
203
4. The title contains both "Fluffy" and "Pancakes", matching our search terms exactly.
206
204
5. The description includes "fluffiest" and "pancakes", further contributing to the document's relevance due to the analysis process.
@@ -275,7 +273,7 @@ GET /cooking_blog/_search
275
273
276
274
When users enter a search query, they often don't know (or care) whether their search terms appear in a specific field. A [`multi_match`](/reference/query-languages/query-dsl/query-dsl-multi-match-query.md) query allows searching across multiple fields simultaneously.
277
275
278
-
Let's start with a basic `multi_match` query:
276
+
Start with a basic `multi_match` query:
279
277
280
278
```console
281
279
GET /cooking_blog/_search
@@ -291,7 +289,8 @@ GET /cooking_blog/_search
291
289
292
290
This query searches for "vegetarian curry" across the title, description, and tags fields. Each field is treated with equal importance.
293
291
294
-
However, in many cases, matches in certain fields (like the title) might be more relevant than others. We can adjust the importance of each field using field boosting:
292
+
However, in many cases, matches in certain fields (like the title) might be more relevant than others.
293
+
You can adjust the importance of each field using field boosting:
295
294
296
295
```console
297
296
GET /cooking_blog/_search
@@ -395,8 +394,8 @@ GET /cooking_blog/_search
395
394
::::{tip}
396
395
The `.keyword` suffix accesses the unanalyzed version of a field, enabling exact, case-sensitive matching. This works in two scenarios:
397
396
398
-
1.**When using dynamic mapping for text fields**. Elasticsearch automatically creates a `.keyword` sub-field.
399
-
2.**When text fields are explicitly mapped with a `.keyword` sub-field**. For example, we explicitly mapped the `category` field [in an earlier step](#full-text-filter-tutorial-create-index) of this tutorial.
397
+
1.**When using dynamic mapping for text fields**. {{es}} automatically creates a `.keyword` sub-field.
398
+
2.**When text fields are explicitly mapped with a `.keyword` sub-field**. For example, you explicitly mapped the `category` field [in an earlier step](#full-text-filter-tutorial-create-index) of this tutorial.
400
399
401
400
::::
402
401
@@ -448,7 +447,7 @@ Avoid using the `term` query for [`text` fields](/reference/elasticsearch/mappin
448
447
449
448
A [`bool`](/reference/query-languages/query-dsl/query-dsl-bool-query.md) query allows you to combine multiple query clauses to create sophisticated searches. In this tutorial, it's useful when users have complex requirements for finding recipes.
450
449
451
-
Let's create a query that addresses the following user needs:
450
+
Create a query that addresses the following user needs:
452
451
453
452
* Must be a vegetarian recipe
454
453
* Should contain "curry" or "spicy" in the title or description
@@ -562,9 +561,11 @@ GET /cooking_blog/_search
562
561
563
562
## Learn more [full-text-filter-tutorial-learn-more]
564
563
565
-
This tutorial introduced the basics of full-text search and filtering in {{es}}. Building a real-world search experience requires understanding many more advanced concepts and techniques. The following resources will help you dive deeper:
564
+
This tutorial introduced the basics of full-text search and filtering in {{es}}.
565
+
Building a real-world search experience requires understanding many more advanced concepts and techniques.
566
+
The following resources will help you dive deeper:
566
567
567
568
*[Full-text search](docs-content://solutions/search/full-text.md): Learn about the core components of full-text search in {{es}}.
568
-
*[Elasticsearch basics — Search and analyze data](docs-content://explore-analyze/query-filter.md): Understand all your options for searching and analyzing data in {{es}}.
569
+
*[{{es}} basics — Search and analyze data](docs-content://explore-analyze/query-filter.md): Understand all your options for searching and analyzing data in {{es}}.
569
570
*[Text analysis](docs-content://solutions/search/full-text/text-analysis-during-search.md): Understand how text is processed for full-text search.
570
571
*[Search your data](docs-content://solutions/search.md): Learn about more advanced search techniques using the `_search` API, including semantic search.
0 commit comments