Build your search queries
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.
Once you know which 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 | _search |
Original, JSON-based query language native to Elasticsearch. Expressive and well-supported across all client libraries. |
| Retrievers | _search |
Composable _search API syntax for building multi-stage retrieval pipelines in a single request. Built on top of Query DSL. |
| ES|QL | _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.
Use the following guidance to decide which interface best fits your use case.
Choose Query DSL 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, ortermquery 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.
Choose retrievers when you need to:
- Compose multi-stage retrieval pipelines in a single
_searchcall (for example, retrieve → rerank → diversify) - Combine multiple retrieval strategies using RRF or linear combination
- Apply semantic reranking with the
text_similarity_rerankerretriever - 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.
Choose ES|QL 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 withRERANK, and text generation withCOMPLETION - 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.
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 |
You can use the Elasticsearch REST APIs to search your data using any HTTP client, including the Elasticsearch client libraries, or directly in Console. You can also run searches using Discover in the UI.
Try our hands-on quickstart guides to get started, or check out our Python notebooks.