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
- Rename file
- Incorporate @aznick's feedback:
- Expanded **semantic search** coverage: now includes semantic indexing,
searching, and hybrid search with examples and explanations.
- Moved semantic search from a “bonus” section to a core step (Step 4).
- Added notes/tips on relevance scoring with `_score` and sorting.
- Reorganized and clarified filter vs search distinctions.
- Appended **related blog posts** section at the end.
Copy file name to clipboardExpand all lines: explore-analyze/query-filter/languages/esql-getting-started.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -423,5 +423,5 @@ For more about data processing with {{esql}}, refer to [Data processing with DIS
423
423
424
424
To learn more about {{esql}}, refer to [{{esql}} reference](elasticsearch://reference/query-languages/esql.md).
425
425
426
-
Learn more about using {{esql}} for Search use cases in this tutorial: [Search and filter with {{esql}}](/solutions/search/esql-full-text-filter-tutorial.md).
426
+
Learn more about using {{esql}} for Search use cases in this tutorial: [Search and filter with {{esql}}](/solutions/search/esql-search-tutorial.md).
Copy file name to clipboardExpand all lines: explore-analyze/query-filter/languages/esql.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ You can use it:
35
35
- In your queries to {{es}} APIs, using the [`_query` endpoint](/explore-analyze/query-filter/languages/esql-rest.md) that accepts queries written in {{esql}} syntax.
36
36
- Within various {{kib}} tools such as Discover and Dashboards, to explore your data and build powerful visualizations.
37
37
38
-
Learn more about using {{esql}} for Search use cases in this tutorial: [Search and filter with {{esql}}](/solutions/search/esql-full-text-filter-tutorial.md).
38
+
Learn more about using {{esql}} for Search use cases in this tutorial: [Search and filter with {{esql}}](/solutions/search/esql-search-tutorial.md).
Copy file name to clipboardExpand all lines: solutions/search/api-quickstarts.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Use the following quickstarts to get hands-on experience with Elasticsearch APIs
15
15
-[Basic full-text search and filtering in Elasticsearch](querydsl-full-text-filter-tutorial.md): Learn about different options for querying data, including full-text search and filtering, using the Query DSL.
16
16
-[Analyze eCommerce data with aggregations using Query DSL](/explore-analyze/query-filter/aggregations/tutorial-analyze-ecommerce-data-with-aggregations-using-query-dsl.md): Learn how to analyze data using different types of aggregations, including metrics, buckets, and pipelines.
17
17
% - [Getting started with {{esql}}](esql-getting-started.md): Learn how to query and aggregate your data using {{esql}}.
18
-
-[Search and filter with {{esql}}](esql-full-text-filter-tutorial.md): Learn how to perform full-text and semantic search in {{esql}}, combined with filtering.
18
+
-[Search and filter with {{esql}}](esql-search-tutorial.md): Learn how to perform full-text and semantic search in {{esql}}, combined with filtering.
19
19
-[Semantic search](semantic-search/semantic-search-semantic-text.md): Learn how to create embeddings for your data with `semantic_text` and query using the `semantic` query.
20
20
-[Hybrid search](hybrid-semantic-text.md): Learn how to combine semantic search using`semantic_text` with full-text search.
21
21
-[Bring your own dense vector embeddings](vector/bring-own-vectors.md): Learn how to ingest dense vector embeddings into Elasticsearch.
Copy file name to clipboardExpand all lines: solutions/search/esql-search-tutorial.md
+86-55Lines changed: 86 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,11 @@ navigation_title: "Search and filter with ES|QL"
8
8
This tutorial presents examples in {{esql}} syntax. Refer to [the Query DSL version](querydsl-full-text-filter-tutorial.md) for the equivalent examples in Query DSL syntax.
9
9
:::
10
10
11
-
This is a hands-on introduction to the basics of [full-text search](full-text.md) with Elasticsearch, also known as *lexical search*, and how to filter search results based on exact criteria. In this scenario, we're implementing a search function for a cooking blog. The blog contains recipes with various attributes including textual content, categorical data, and numerical ratings.
11
+
This is a hands-on introduction to the basics of full-text search and semantic search, using [{{esql}}](/explore-analyze/query-filter/languages/esql.md).
12
12
13
-
This tutorial covers lexical search, with a brief [introductory section on semantic search](#bonus-semantic-search-with-esql) at the end.
13
+
% TODO For an overview of all the search capabilities in {{esql}}, refer to [Search with {{esql}}](elasticsearch://reference/query-languages/esql/esql-for-search.md).
14
+
15
+
In this scenario, we're implementing search for a cooking blog. The blog contains recipes with various attributes including textual content, categorical data, and numerical ratings.
14
16
15
17
## Requirements
16
18
@@ -147,10 +149,12 @@ Full-text search involves executing text-based queries across one or more docume
147
149
:::{tip}
148
150
{{esql}} provides two ways to perform full-text searches:
149
151
150
-
1. Full match function syntax: `match(field, "search terms")`
151
-
1. Compact syntax using the match operator "`:`": `field:"search terms"`
152
+
1. Full [match function](elasticsearch://reference/query-languages/esql/esql-functions-operators.md#esql-match) syntax: `match(field, "search terms")`
153
+
1. Compact syntax using the [match operator `:`](elasticsearch://reference/query-languages/esql/esql-functions-operators.md#esql-search-operators): `field:"search terms"`
152
154
153
155
Both are equivalent and can be used interchangeably. The compact syntax is more concise, while the function syntax allows for more configuration options. We'll use the compact syntax in most examples for brevity.
156
+
157
+
Refer to the [match function](elasticsearch://reference/query-languages/esql/esql-functions-operators.md#esql-match) reference docs for advanced parameters available with the function syntax.
154
158
:::
155
159
156
160
### Basic full-text query
@@ -163,6 +167,10 @@ FROM cooking_blog # Specify the index to search
163
167
| LIMIT 1000 # Return up to 1000 results
164
168
```
165
169
170
+
:::{note}
171
+
The results ordering isn't by relevance, as we haven't requested the `_score` metadata field. We'll cover relevance scoring in the next section.
172
+
:::
173
+
166
174
By default, like the Query DSL `match` query, {{esql}} uses `OR` logic between terms. This means it will match documents that contain either "fluffy" or "pancakes", or both, in the description field.
167
175
168
176
:::{tip}
@@ -200,7 +208,67 @@ FROM cooking_blog
200
208
201
209
This query searches the title field to match at least 2 of the 3 terms: "fluffy", "pancakes", or "breakfast".
202
210
203
-
## Step 4: Search across multiple fields at once
211
+
## Step 4: Semantic search and hybrid search
212
+
213
+
### Index semantic content
214
+
215
+
{{es}} allows you to semantically search for documents based on the meaning of the text, rather than just the presence of specific keywords. This is useful when you want to find documents that are conceptually similar to a given query, even if they don't contain the exact search terms.
216
+
217
+
ES|QL supports semantic search when your mappings include fields of the [`semantic_text`](elasticsearch://reference/elasticsearch/mapping-reference/semantic-text.md) type. This example mapping update adds a new field called `semantic_description` with the type `semantic_text`:
218
+
219
+
```console
220
+
PUT /cooking_blog/_mapping
221
+
{
222
+
"properties": {
223
+
"semantic_description": {
224
+
"type": "semantic_text"
225
+
}
226
+
}
227
+
}
228
+
```
229
+
230
+
Next, index a document with content into the new field:
231
+
232
+
```console
233
+
POST /cooking_blog/_doc
234
+
{
235
+
"title": "Mediterranean Quinoa Bowl",
236
+
"semantic_description": "A protein-rich bowl with quinoa, chickpeas, fresh vegetables, and herbs. This nutritious Mediterranean-inspired dish is easy to prepare and perfect for a quick, healthy dinner.",
Once the document has been processed by the underlying model running on the inference endpoint, you can perform semantic searches. Here's an example natural language query against the `semantic_description` field:
248
+
249
+
```esql
250
+
FROM cooking_blog
251
+
| WHERE semantic_description:"What are some easy to prepare but nutritious plant-based meals?"
252
+
| LIMIT 5
253
+
```
254
+
255
+
:::{tip}
256
+
Follow this [tutorial](/solutions/search/semantic-search/semantic-search-semantic-text.md) if you'd like to test out the semantic search workflow against a large dataset.
257
+
:::
258
+
259
+
### Perform hybrid search
260
+
261
+
You can combine full-text and semantic queries. In this example we combine full-text and semantic search with custom weights:
262
+
263
+
```esql
264
+
FROM cooking_blog METADATA _score
265
+
| WHERE match(semantic_description, "easy to prepare vegetarian meals", { "boost": 0.75 })
266
+
OR match(tags, "vegetarian", { "boost": 0.25 })
267
+
| SORT _score DESC
268
+
| LIMIT 5
269
+
```
270
+
271
+
## Step 5: Search across multiple fields at once
204
272
205
273
When users enter a search query, they often don't know (or care) whether their search terms appear in a specific field. {{esql}} provides ways to search across multiple fields simultaneously:
206
274
@@ -225,14 +293,14 @@ FROM cooking_blog METADATA _score # Request _score metadata for relevance-based
225
293
```
226
294
227
295
:::{tip}
228
-
When working with relevance scoring in ES|QL, it's important to understand how `_score` works. If you don't include `METADATA _score` in your query, you're only performing filtering operations with no relevance calculation.
296
+
When working with relevance scoring in ES|QL, it's important to understand `_score`. If you don't include `METADATA _score` in your query, you won't see relevance scores in your results. This means you won't be able to sort by relevance or filter based on relevance scores.
229
297
230
298
When you include `METADATA _score`, search functions included in WHERE conditions contribute to the relevance score. Filtering operations (like range conditions and exact matches) don't affect the score.
231
299
232
-
Remember that including `METADATA _score` doesn't automatically sort your results by relevance. You must explicitly use`SORT _score DESC` or `SORT _score ASC` to order your results by relevance.
300
+
If you want the most relevant results first, you must sort by `_score`, by explicitly using`SORT _score DESC` or `SORT _score ASC`.
233
301
:::
234
302
235
-
## Step 5: Filter and find exact matches
303
+
## Step 6: Filter and find exact matches
236
304
237
305
Filtering allows you to narrow down your search results based on exact criteria. Unlike full-text searches, filters are binary (yes/no) and do not affect the relevance score. Filters execute faster than queries because excluded results don't need to be scored.
238
306
@@ -271,7 +339,7 @@ FROM cooking_blog
271
339
272
340
Like the `term` query in Query DSL, this has zero flexibility and is case-sensitive.
273
341
274
-
## Step 6: Combine multiple search criteria
342
+
## Step 7: Combine multiple search criteria
275
343
276
344
Complex searches often require combining multiple search criteria:
277
345
@@ -304,55 +372,18 @@ FROM cooking_blog METADATA _score
304
372
305
373
```
306
374
307
-
## Bonus: Semantic search with ES|QL
308
-
309
-
ES|QL also supports semantic search when your mappings include fields of the [`semantic_text`](elasticsearch://reference/elasticsearch/mapping-reference/semantic-text.md) type. This example mapping update adds a new field called `semantic_description` with the type `semantic_text`:
310
-
311
-
```console
312
-
PUT /cooking_blog/_mapping
313
-
{
314
-
"properties": {
315
-
"semantic_description": {
316
-
"type": "semantic_text"
317
-
}
318
-
}
319
-
}
320
-
```
321
-
322
-
Next, index a document with content into the new field:
323
-
324
-
```console
325
-
POST /cooking_blog/_doc
326
-
{
327
-
"title": "Mediterranean Quinoa Bowl",
328
-
"semantic_description": "A protein-rich bowl with quinoa, chickpeas, fresh vegetables, and herbs. This nutritious Mediterranean-inspired dish is easy to prepare and perfect for a quick, healthy dinner.",
Once the document has been processed by the underlying model running on the inference endpoint, you can perform semantic searches. Here's an example natural language query against the `semantic_description` field:
338
-
339
-
```esql
340
-
FROM cooking_blog
341
-
| WHERE semantic_description:"What are some easy to prepare but nutritious plant-based meals?"
342
-
| LIMIT 5
343
-
344
-
```
345
-
346
-
:::{tip}
347
-
Follow this [tutorial](/solutions/search/semantic-search/semantic-search-semantic-text.md) if you'd like to test out the semantic search workflow against a large dataset.
348
-
:::
349
-
350
375
## Learn more
351
376
377
+
### Documentation
378
+
352
379
This tutorial introduced the basics of search and filtering in {{esql}}. Building a real-world search experience requires understanding many more advanced concepts and techniques. Here are some resources once you're ready to dive deeper:
353
380
354
-
-[Full-text search](full-text.md): Learn about the core components of full-text search in Elasticsearch.
355
-
-[Text analysis](full-text/text-analysis-during-search.md): Understand how text is processed for full-text search.
381
+
% TODO [Search with {{esql}}](): Learn about all your options for search use cases with {{esql}}.
356
382
-[{{esql}} search functions](elasticsearch://reference/query-languages/esql/esql-functions-operators.md#esql-search-functions): Explore the full list of search functions available in {{esql}}.
357
383
-[Semantic search](/solutions/search/semantic-search.md): Understand your various options for semantic search in Elasticsearch.
358
-
-[The `semantic_text` workflow](/solutions/search/semantic-search.md#_semantic_text_workflow): Learn how to use the `semantic_text` field type for semantic search. This is the recommended approach for most users looking to perform semantic search in {{es}}, because it abstracts away the complexity of setting up inference endpoints and models.
384
+
-[The `semantic_text` workflow](/solutions/search/semantic-search.md#_semantic_text_workflow): Learn how to use the `semantic_text` field type for semantic search. This is the recommended approach for most users looking to perform semantic search in {{es}}, because it abstracts away the complexity of setting up inference endpoints and models.
385
+
386
+
### Related blog posts
387
+
388
+
% TODO [[uncomment once blog is live]] - https://www.elastic.co/blog/esql-you-know-for-search-scoring-semantic-search[ES|QL, you know for Search]: Introducing scoring and semantic search
389
+
-[Introducing full text filtering in ES|QL](https://www.elastic.co/blog/introducing-full-text-filtering-with-esql): Overview of text filtering capabilities
Copy file name to clipboardExpand all lines: solutions/search/querydsl-full-text-filter-tutorial.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ applies_to:
10
10
# Tutorial: Full-text search and filtering with Query DSL [full-text-filter-tutorial]
11
11
12
12
:::{tip}
13
-
This tutorial presents examples in Query DSL syntax. Refer to [the {{esql}} version](esql-full-text-filter-tutorial.md) for the equivalent examples in {{esql}} syntax.
13
+
This tutorial presents examples in Query DSL syntax. Refer to [the {{esql}} version](esql-search-tutorial.md) for the equivalent examples in {{esql}} syntax.
14
14
:::
15
15
16
16
This is a hands-on introduction to the basics of [full-text search](full-text.md) with {{es}}, also known as *lexical search*, using the [`_search` API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search) and [Query DSL](../../explore-analyze/query-filter/languages/querydsl.md). You’ll also learn how to filter data, to narrow down search results based on exact criteria.
0 commit comments