# ElasticSearch Search *author: Jael*
## Description The search operator runs a search via ElasticSearch client given a query. It takes a dictionary as input, which should be written in [Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html). To use this operator, you need to [set up ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html) in advance.
## Code Example With an example ElasticSearch client 'localhost:9200', search across the index 'test_index' using an example query `{'match_all': {}}` to get all documents. ```python from towhee import pipe, ops, DataCollection query = {'match_all': {}} es_search = ( pipe.input('index_name', 'query') .map(('index_name', 'query'), 'res', ops.elasticsearch.osschat_search( host='localhost', port=9200 )) .output('query', 'res') ) res = es_search('test_index', query) DataCollection(res).show() # Optional: display output data ```
## Factory Constructor Create the operator via the following factory method: ***elasticsearch.search(host='localhost', port=9200, user=None, password=None, ca_certs=None)*** **Parameters:** ***host***: *str* The host to connect ElasticSearch client. ***port***: *int* The port to connect ElasticSearch client. ***user***: *str* The username to connect ElasticSearch client if needed, defaults to None. ***password***: *str* The user password to connect ElasticSearch client if needed, defaults to None. ***ca_certs***: *str* The path to CA certificates to connect ElasticSearch client if needed, defaults to None.
**Returns:** Search results wrapped by `elastic_transport.ObjectApiResponse`. # More Resources - [Semantic Search with Milvus and OpenAI - Zilliz blog](https://zilliz.com/learn/semantic-search-with-milvus-and-openai): In this guide, we’ll explore semantic search capabilities through the integration of Milvus and OpenAI’s Embedding API, using a book title search as an example use case. - [Accelerate Similarity Search on Big Data with Vector Indexing - II - Zilliz blog](https://zilliz.com/learn/index-overview-part-2): Discover how indexes dramatically accelerate vector similarity search, different types of indexes, and how to choose the right index for your next AI application. - [What Is Semantic Search?](https://zilliz.com/glossary/semantic-search): Semantic search is a search technique that uses natural language processing (NLP) and machine learning (ML) to understand the context and meaning behind a user's search query. - [ArXiv Papers Vector Similarity Search with Milvus 2.1 - Zilliz blog](https://zilliz.com/blog/Arxiv-scientific-papers-vector-similarity-search): Run semantic search queries on ~640K papers in <50ms using Dask, SBERT SPECTRE, and Milvus Vector database - [Mastering BM25: A Deep Dive into the Algorithm and Its Application in Milvus - Zilliz blog](https://zilliz.com/learn/mastering-bm25-a-deep-dive-into-the-algorithm-and-application-in-milvus): We can easily implement the BM25 algorithm to turn a document and a query into a sparse vector with Milvus. Then, these sparse vectors can be used for vector search to find the most relevant documents according to a specific query. - [The 2024 Playbook: Top Use Cases for Vector Search - Zilliz blog](https://zilliz.com/learn/top-use-cases-for-vector-search): An exploration of vector search technologies and their most popular use cases. - [Simplifying Legal Research with RAG, Milvus, and Ollama - Zilliz blog](https://zilliz.com/blog/simplifying-legal-research-with-rag-milvus-ollama): In this blog post, we will see how we can apply RAG to Legal data. Legal research can be time-consuming. You usually need to review a large number of documents to find the answers you need. Retrieval-Augmented Generation (RAG) can help streamline your research process. - [Evolution of Search: From Keyword Matching to Vector Search and GenAI - Zilliz blog](https://zilliz.com/learn/evolution-of-search-from-traditional-keyword-matching-to-vector-search-and-genai): Explores the evolution of search, the limitations of keyword-matching systems, and how vector search and GenAI are setting new standards for modern search.