Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions solutions/search/esql-for-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
mapped_pages:
- https://www.elastic.co/guide/en/elasticsearch/reference/8.18/esql-for-search.html
applies_to:
stack: preview 9.0, ga 9.1
serverless: ga
stack:
serverless:
products:
- id: elasticsearch
---
Expand All @@ -21,17 +21,27 @@ For a hands-on tutorial check out [Search and filter with {{esql}}](elasticsearc

## {{esql}} search quick reference

The following table summarizes the key search features available in [{{esql}}](elasticsearch://reference/query-languages/esql.md) and when they were introduced, organized chronologically by release.
The following table summarizes the key search features available in [{{esql}}](elasticsearch://reference/query-languages/esql.md) and when they were introduced, organized chronologically by their stack version availability.

:::{note}
Features are usually available on {{serverless-full}} before stack-versioned deployments.
:::

| Feature | Description | Available since |
|---------|-------------|----------------|
| [Match function/operator](#match-function-and-operator) | Perform basic text searches with `MATCH` function or match operator (`:`) | 8.17 |
| [Query string function](#query-string-qstr-function) | Execute complex queries with `QSTR` using Query String syntax | 8.17 |
| [Query string function](#qstr-function) | Execute complex queries with `QSTR` using Query String syntax | 8.17 |
| [Relevance scoring](#esql-for-search-scoring) | Calculate and sort by relevance with `METADATA _score` | 8.18/9.0 |
| [Semantic search](#semantic-search) | Perform semantic searches on `semantic_text` field types | 8.18/9.0 |
| [Hybrid search](#hybrid-search) | Combine lexical and semantic search approaches with custom weights | 8.18/9.0 |
| [Kibana Query Language](#kql-function) | Use Kibana Query Language with the `KQL` function | 8.18/9.0 |
| [Match phrase function](#match_phrase-function) | Perform phrase matching with `MATCH_PHRASE` function | 8.19/9.1 |
| [FORK command](#fork-and-fuse) | Create multiple execution branches to operate on the same input data | 8.19/9.1 |
| [FUSE command](#fork-and-fuse) | Combine and score results from multiple queries for hybrid search | 9.2 |
| [KNN function](#knn-function) | Find k nearest vectors using approximate search on indexed fields | 9.2 |
| [RERANK command](#semantic-reranking-with-rerank) | Re-score search results using inference models for improved relevance | 9.2 |
| [COMPLETION command](#text-generation-with-completion) | Perform arbitrary text generation tasks by calling LLMs | 9.2 |
| [TEXT_EMBEDDING function](#text_embedding-function) | Generate dense vector embeddings using inference endpoints | 9.3 |

## How search works in {{esql}}

Expand Down Expand Up @@ -84,9 +94,9 @@ Use the [`MATCH_PHRASE` function](elasticsearch://reference/query-languages/esql

For exact phrase matching rather than individual word matching, use `MATCH_PHRASE`.

### Query string (`QSTR`) function
### `QSTR` function

The [`qstr` function](elasticsearch://reference/query-languages/esql/functions-operators/search-functions.md#esql-qstr) provides the same functionality as the Query DSL's `query_string` query. This enables advanced search patterns with wildcards, boolean logic, and multi-field searches.
The [`QSTR` function](elasticsearch://reference/query-languages/esql/functions-operators/search-functions.md#esql-qstr) provides the same functionality as the Query DSL's `query_string` query. This enables advanced search patterns with wildcards, boolean logic, and multi-field searches.

For complete details, refer to the [Query DSL `query_string` docs](elasticsearch://reference/query-languages/query-dsl/query-dsl-query-string-query.md).

Expand All @@ -96,6 +106,18 @@ Use the [KQL function](elasticsearch://reference/query-languages/esql/functions-

For migrating queries from other Kibana interfaces, the `KQL` function preserves existing query syntax and allows gradual migration to {{esql}} without rewriting existing Kibana queries.

### `KNN` function

The [`KNN` function](elasticsearch://reference/query-languages/esql/functions-operators/dense-vector-functions.md#esql-knn) finds the k nearest vectors to a query vector, as measured by a similarity metric. It performs approximate search on indexed `dense_vector` or `semantic_text` fields.

Use `KNN` for vector similarity search use cases, such as finding semantically similar documents or implementing recommendation systems based on vector embeddings.

### `TEXT_EMBEDDING` function

The [`TEXT_EMBEDDING` function](elasticsearch://reference/query-languages/esql/functions-operators/dense-vector-functions.md#esql-text_embedding) generates dense vector embeddings from text input using a specified inference endpoint.

Use `TEXT_EMBEDDING` to generate query vectors for KNN searches against your vectorized data or for other dense vector based operations.

## Advanced search capabilities

### Semantic search
Expand All @@ -110,8 +132,25 @@ Refer to [semantic search with semantic_text](/solutions/search/semantic-search/

[Hybrid search](/solutions/search/hybrid-search.md) combines lexical and semantic search with custom weights to leverage both exact keyword matching and semantic understanding.

#### `FORK` and `FUSE`

The [`FORK`](elasticsearch://reference/query-languages/esql/commands/fork.md) and [`FUSE`](elasticsearch://reference/query-languages/esql/commands/fuse.md) commands work together to enable hybrid search in {{esql}}.

`FORK` creates multiple execution branches that operate on the same input data. `FUSE` then combines and scores the results from these branches. Together, these commands allow you to execute different search strategies (such as lexical and semantic searches) in parallel and merge their results with proper relevance scoring.

Refer to [hybrid search with semantic_text](hybrid-semantic-text.md) for an example or follow the [tutorial](elasticsearch://reference/query-languages/esql/esql-search-tutorial.md#step-5-semantic-search-and-hybrid-search).

### Text generation with `COMPLETION`

The [`COMPLETION` command](elasticsearch://reference/query-languages/esql/commands/completion.md) sends prompts to a Large Language Model (LLM) for text generation tasks.

Use `COMPLETION` for question answering, summarization, translation, or other AI-powered text generation.


### Semantic reranking with `RERANK`

Use the [`RERANK` command](elasticsearch://reference/query-languages/esql/commands/rerank.md) to re-score search results using inference models for improved relevance.

## Next steps [esql-for-search-next-steps]

### Tutorials and how-to guides [esql-for-search-tutorials]
Expand Down