﻿---
title: Build your search queries
description: Once you know which search approaches you need to use, you can start building and testing your search queries. Elasticsearch provides several query interfaces...
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/querying-for-search
products:
  - Elastic Cloud Serverless
  - Elasticsearch
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Generally available
---

# Build your search queries
<tip>
  This page is focused on the search use case. For an overview of Elastic query languages for every use case, refer to the [complete overview](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/explore-analyze/query-filter/languages).
</tip>

Once you know which [search approaches](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/search-approaches) you need to use, you can start building and testing your search queries. Elasticsearch provides several query interfaces to help you express your search logic.

| Interface                                                                                                                           | Endpoint                                                                                                        | Description                                                                                                                                                                |
|-------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [**Query DSL**](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/explore-analyze/query-filter/languages/querydsl) | [`_search`](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/the-search-api) | Original, JSON-based query language native to Elasticsearch. Expressive and well-supported across all client libraries.                                                    |
| [**Retrievers**](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/retrievers-overview)           | [`_search`](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/the-search-api) | Composable `_search` API syntax for building multi-stage retrieval pipelines in a single request. Built on top of Query DSL.                                               |
| [**ES|QL**](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/esql-for-search)                    | `_query`                                                                                                        | Piped query language with SQL-like syntax, built on a new compute architecture. Supports full-text search, semantic search, hybrid search, reranking, and text generation. |

These query interfaces are complementary, not mutually exclusive. You can use different interfaces for different parts of your application, based on your specific needs. This flexibility allows you to gradually adopt newer interfaces as your requirements evolve.

## Choosing the right interface

Use the following guidance to decide which interface best fits your use case.

### Query DSL

Choose [Query DSL](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/explore-analyze/query-filter/languages/querydsl) when you need:
- **Fine-grained control** over individual query clauses, scoring, and boosting
- **The widest ecosystem support** — all Elasticsearch clients, tools, and integrations work with Query DSL
- **A single-stage query** like a `match`, `bool`, or `term` query without multi-stage retrieval

Query DSL is the foundational query language and remains the right choice for straightforward search queries, especially when you're using a single retrieval strategy.

### Retrievers

Choose [retrievers](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/retrievers-overview) when you need to:
- **Compose multi-stage retrieval pipelines** in a single `_search` call (for example, retrieve → rerank → diversify)
- **Combine multiple retrieval strategies** using RRF or linear combination
- **Apply semantic reranking** with the `text_similarity_reranker` retriever
- **Use the multi-field query format** for simple hybrid search across lexical and semantic fields with automatic score normalization

Retrievers wrap Query DSL and add composability. If your search involves multiple retrieval stages — such as combining BM25 with vector search, or adding a reranking step — retrievers let you express the entire pipeline declaratively.

### ES|QL

Choose [ES|QL](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/esql-for-search) when you need to:
- **Transform or aggregate results** alongside your search (for example, filter → search → rerank → generate)
- **Build end-to-end search workflows** using piped syntax, including hybrid search with `FORK`/`FUSE`, reranking with `RERANK`, and text generation with `COMPLETION`
- **Explore data interactively** using a familiar SQL-like syntax in Kibana or the API
- **Combine search with analytics** such as aggregations, stats, or data transformations in a single query

ES|QL is a good fit when your workflow extends beyond retrieval — for example, when you want to search, rerank, and summarize results in a single piped query.

### Feature comparison

The following table summarizes which capabilities are available in each interface.

| Capability                        | Query DSL | Retrievers                       | ES|QL              |
|-----------------------------------|-----------|----------------------------------|--------------------|
| Full-text search (BM25)           | Yes       | Yes                              | Yes                |
| Semantic / vector search          | Yes       | Yes                              | Yes                |
| Hybrid search (score combination) | —         | Yes (RRF, linear)                | Yes (FORK/FUSE)    |
| Semantic reranking                | —         | Yes (`text_similarity_reranker`) | Yes (`RERANK`)     |
| Result diversification (MMR)      | —         | Yes (`diversify`)                | Yes (`MMR`)        |
| Multi-field query format          | —         | Yes                              | —                  |
| Aggregations                      | Yes       | Yes                              | Yes                |
| Text generation (LLM)             | —         | —                                | Yes (`COMPLETION`) |
| Piped transformations             | —         | —                                | Yes                |

<note>
  You can use the [Elasticsearch REST APIs](https://www.elastic.co/docs/api/doc/elasticsearch/) to search your data using any HTTP client, including the [Elasticsearch client libraries](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/site-or-app/clients), or directly in [Console](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/explore-analyze/query-filter/tools/console). You can also run searches using [Discover](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/explore-analyze/discover) in the UI.
</note>

<tip>
  Try our hands-on [quickstart guides](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/6447/solutions/search/get-started/quickstarts) to get started, or check out our [Python notebooks](https://github.com/elastic/elasticsearch-labs/tree/main/notebooks#readme).
</tip>