MS Azure Cognitive Search Docs

Azure Cognitive Search

Azure Cognitive Search is a fully managed search-as-a-service that provides powerful and scalable indexing and querying capabilities for your applications.

Getting Started

Follow the steps below to create your first search service.

Azure Portal
Azure CLI
ARM Template
  1. Sign in to the Azure portal.
  2. Search for Cognitive Search and select Create.
  3. Configure the service name, subscription, region, and pricing tier.
  4. Click Review + create then Create.
az group create --name MyResourceGroup --location eastus
az search service create \
  --name mysearchservice \
  --resource-group MyResourceGroup \
  --location eastus \
  --sku Standard
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Search/searchServices",
      "apiVersion": "2023-11-01",
      "name": "mysearchservice",
      "location": "eastus",
      "sku": { "name": "standard" },
      "properties": {}
    }
  ]
}

Indexing Data

Use a data source, skillset, and indexer to ingest and enrich content.

Sample Index Definition

{
  "name": "products",
  "fields": [
    {"name":"productId","type":"Edm.String","key":true,"filterable":true},
    {"name":"title","type":"Edm.String","searchable":true,"retrievable":true},
    {"name":"description","type":"Edm.String","searchable":true},
    {"name":"price","type":"Edm.Double","filterable":true,"sortable":true},
    {"name":"category","type":"Edm.String","facetable":true}
  ]
}
Create Indexer →

Querying the Index

Use REST or SDKs. Below is a REST example for a full-text search.

GET https://mysearchservice.search.windows.net/indexes/products/docs?api-version=2024-09-01-Preview&search=wireless
api-key: <admin-key>

Response:
{
  "value": [
    {
      "@search.score": 1.23,
      "productId": "123",
      "title": "Wireless Mouse",
      "description": "Ergonomic wireless mouse",
      "price": 29.99,
      "category": "Accessories"
    }
  ]
}

SDK (JavaScript) example:

import { SearchClient, AzureKeyCredential } from "@azure/search-documents";

const endpoint = "https://mysearchservice.search.windows.net";
const indexName = "products";
const credential = new AzureKeyCredential("");
const client = new SearchClient(endpoint, indexName, credential);

const results = await client.search("wireless", {
  filter: "price lt 50",
  select: ["title","price","category"]
});

for await (const result of results) {
  console.log(result);
}

Security & Authentication

Azure Cognitive Search supports API keys, Azure AD, and managed identities.

Resources