This repository contains Java code samples used in Azure AI Search documentation. Unless noted otherwise, all samples run on the shared (free) pricing tier of an Azure AI Search service.
-
Use the main branch for code samples that call the Azure AI Search client library for Java.
-
Use the java-rest-api branch for older code samples that call the AI Search REST APIs.
| Sample | Description |
|---|---|
| quickstart | "Day One" introduction to the fundamental tasks of working with a search index: create, load, and query. This Java console app uses a subset of the hotels demo data set, using just 4 documents as a test case. This sample is built on the Microsoft Build of OpenJDK using the Maven build system. This sample has a dependency on the Azure AI Search client library. |
| rag-quickstart | Retrieval-Augmented Generation (RAG) pattern using Azure AI Search for retrieval and Azure OpenAI for generation. This Java sample demonstrates how to query a search index using semantic search and use retrieved documents to generate natural language responses via a chat completion model. Requires Azure OpenAI Service with a chat completion model (such as gpt-4o or gpt-4o-mini). This sample is built on Java 21 (LTS) from the Microsoft Build of OpenJDK using the Maven build system. This sample has dependencies on the Azure AI Search, Azure OpenAI, and Azure Identity client libraries. |
| vector-quickstart | Vector search capabilities using Azure AI Search with HNSW algorithm. This Java sample demonstrates how to create an index with vector field configurations, load documents with pre-computed embeddings, and execute vector similarity searches and hybrid queries. Requires Azure AI Search Basic tier or higher. This sample is built on Java 21 (LTS) from the Microsoft Build of OpenJDK using the Maven build system. This sample has dependencies on the Azure AI Search and Azure Identity client libraries. |
| semantic-ranking-quickstart | Semantic ranking capabilities to improve search relevance using Azure AI Search. This Java sample demonstrates how to create an index with semantic configuration, load documents, and execute queries with semantic ranking to get improved relevance scoring and semantic captions. Requires Azure AI Search Standard tier or higher with semantic ranking enabled. This sample is built on the Microsoft Build of OpenJDK using the Maven build system. This sample has dependencies on the Azure Search Documents and Azure Identity client libraries. |