azuresearch

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 63 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Parity grade: B · SDK azure-sdk-for-go/sdk/resourcemanager/search/armsearch@v1.4.0 · last audited 2026-11-05 (4900f0e6f)

Coverage

Metric Value
PARITY entries audited 19 (10 ok, 9 partial)
Feature families 4 (2 ok, 2 partial)
Known gaps 4
Deferred items 0
Resource leaks clean
Known gaps
  • Semantic ranking, spell correction and answers/captions need Microsoft's ranking models (queryType semantic is rejected with 400, whatever the service's semanticSearch setting); text queries through azureOpenAI/aiServicesVision/aml vectorizers and imageUrl/imageBinary vector queries need a hosted embedding model that no emulator in services/ provides (400).
  • Indexers: no document cracking for PDF/Office/images (no parser dependency in go.mod), DocumentExtraction and Custom.WebApiSkill (the run holds the backend lock in finishRun, indexers.go; an HTTP call needs the run split into load, enrich and apply phases), no knowledge store projections, enrichment cache or index projections, and model-backed skills (OCR, entities, key phrases, language detection, translation, embedding) are recorded as warnings and skipped.
  • Analyzers: Microsoft language analyzers and tokenizers (proprietary), the phonetic, hindi/indic/sorani/scandinavian normalization filters, light and minimal stemmers and KStem, and Lucene's stop word sets for languages other than en, fr, de, es are not implemented; token offsets after a char filter refer to the filtered text, the COMMENTS regex flag is rejected (RE2 has no equivalent), and normalizers are rejected.
  • ARM: network security perimeter configurations (no Microsoft.Network/networkSecurityPerimeters emulation exists to associate with) and semanticSearch (round-trips only; no ranker to enable) are not implemented.

More

Documentation

Overview

Package azuresearch emulates the Azure AI Search data plane: indexes, documents, full-text, filter, facet, vector and hybrid queries, suggesters, synonym maps, data sources, indexers and skillsets, authenticated with admin and query api-keys that the ARM plane manages. See PARITY.md.

Index

Constants

View Source
const DefaultPollInterval = 30 * time.Second

DefaultPollInterval is how often the indexer scheduler checks for due schedules.

View Source
const DefaultPort = 10015

DefaultPort is the Azure AI Search data-plane HTTPS port.

Variables

View Source
var (
	ErrServiceNotFound   = errors.New("azuresearch: search service not found")
	ErrIndexNotFound     = errors.New("azuresearch: index not found")
	ErrObjectNotFound    = errors.New("azuresearch: object not found")
	ErrDocumentNotFound  = errors.New("azuresearch: document not found")
	ErrQueryKeyNotFound  = errors.New("azuresearch: query key not found")
	ErrQueryKeyNameTaken = errors.New("azuresearch: query key name already in use")
	ErrBadRequest        = errors.New("azuresearch: bad request")
	ErrPrecondition      = errors.New("azuresearch: precondition failed")
	ErrConflict          = errors.New("azuresearch: conflict")
	ErrIndexInUse        = errors.New("azuresearch: index is referenced by an indexer")
	ErrUnauthorized      = errors.New("azuresearch: unauthorized")
	ErrForbidden         = errors.New("azuresearch: forbidden")
	ErrTooLarge          = errors.New("azuresearch: request entity too large")
	ErrQuota             = errors.New("azuresearch: service quota exceeded")
	ErrNilAppContext     = errors.New("azuresearch: nil app context")
	ErrKeyKind           = errors.New("azuresearch: key kind must be primary or secondary")
)

Backend errors.

View Source
var ErrSourceUnavailable = errors.New("azuresearch: data source emulator is not available")

ErrSourceUnavailable is returned when no in-process data source emulator is wired.

Functions

This section is empty.

Types

type AdminKeys

type AdminKeys struct {
	Primary   string
	Secondary string
}

AdminKeys is the admin key pair of a service.

type Analyzer

type Analyzer func(text string) []Token

Analyzer turns text into tokens.

type BlobEntry

type BlobEntry struct {
	LastModified time.Time
	Metadata     map[string]string
	Name         string
	ContentType  string
	ETag         string
	MD5          string
	Size         int64
}

BlobEntry describes one blob of the in-process Blob Storage emulator.

type BlobSource

type BlobSource interface {
	ListBlobs(container string) ([]BlobEntry, error)
	ReadBlob(container, name string) ([]byte, error)
}

BlobSource reads blobs from the in-process Blob Storage emulator.

type ConfigProvider

type ConfigProvider interface {
	GetAzureSearchSettings() Settings
}

ConfigProvider extracts the Azure AI Search settings from the AppContext config.

type CosmosDoc

type CosmosDoc struct {
	Timestamp time.Time
	Body      map[string]any
	ID        string
	ETag      string
}

CosmosDoc is one document of the in-process Cosmos DB emulator.

type CosmosSource

type CosmosSource interface {
	ListDocuments(database, container string) ([]CosmosDoc, error)
}

CosmosSource reads documents from the in-process Cosmos DB emulator.

type Doc

type Doc struct {
	Fields map[string]any `json:"fields"`

	Seq int64 `json:"seq"`
	// contains filtered or unexported fields
}

Doc is one stored document.

type Handler

type Handler struct {
	Backend   *InMemoryBackend
	Authority TokenAuthority

	Settings Settings
	Port     int
	// contains filtered or unexported fields
}

Handler owns the HTTPS listener and the indexer scheduler.

func NewHandler

func NewHandler(backend *InMemoryBackend, settings Settings) *Handler

NewHandler returns a Handler over backend.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation implements service.Service.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource implements service.Service.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations implements service.Service.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the echo handler of the HTTPS listener.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority implements service.Registerable.

func (*Handler) Name

func (h *Handler) Name() string

Name implements service.Service.

func (*Handler) Reset

func (h *Handler) Reset()

Reset implements service.Resettable.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: Azure AI Search listens on its own port.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown implements service.Shutdowner.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the HTTPS listener and starts the indexer scheduler.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend holds every search service; the ARM and data planes share it.

func NewInMemoryBackend

func NewInMemoryBackend(opts ...Option) *InMemoryBackend

NewInMemoryBackend returns an empty backend using the wall clock.

func (*InMemoryBackend) CreateQueryKey

func (b *InMemoryBackend) CreateQueryKey(name, keyName string) (QueryKey, error)

CreateQueryKey adds a named query key.

func (*InMemoryBackend) DeleteQueryKey

func (b *InMemoryBackend) DeleteQueryKey(name, key string) error

DeleteQueryKey removes the query key whose value is key.

func (*InMemoryBackend) DeleteService

func (b *InMemoryBackend) DeleteService(name string) error

DeleteService removes the service and all its content.

func (*InMemoryBackend) EncryptionCompliance

func (b *InMemoryBackend) EncryptionCompliance(name string) string

EncryptionCompliance reports Compliant unless enforcement is Enabled and some object lacks an encryptionKey.

func (*InMemoryBackend) HasService

func (b *InMemoryBackend) HasService(name string) bool

HasService reports whether a service exists.

func (*InMemoryBackend) Keys

func (b *InMemoryBackend) Keys(name string) (AdminKeys, error)

Keys returns the service's admin keys.

func (*InMemoryBackend) ListQueryKeys

func (b *InMemoryBackend) ListQueryKeys(name string) ([]QueryKey, error)

ListQueryKeys returns the service's query keys; the default key has an empty name.

func (*InMemoryBackend) PutService

func (b *InMemoryBackend) PutService(name string, cfg ServiceConfig) (time.Time, error)

PutService creates the service or updates its configuration, returning its creation time.

func (*InMemoryBackend) RegenerateAdminKey

func (b *InMemoryBackend) RegenerateAdminKey(name, kind string) (AdminKeys, error)

RegenerateAdminKey replaces the primary or secondary admin key.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset drops all state.

func (*InMemoryBackend) ResetIndexer

func (b *InMemoryBackend) ResetIndexer(service, name string) error

ResetIndexer clears the indexer's change-tracking state so the next run reprocesses everything.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*InMemoryBackend) RunDue

func (b *InMemoryBackend) RunDue() int

RunDue runs every enabled, scheduled indexer whose next run time has passed; it returns the runs made.

func (*InMemoryBackend) RunIndexer

func (b *InMemoryBackend) RunIndexer(service, name string) error

RunIndexer starts the named indexer; the run executes on the backend's executor and is reported as inProgress until it finishes.

func (*InMemoryBackend) ServiceNames

func (b *InMemoryBackend) ServiceNames() []string

ServiceNames lists the services, sorted.

func (*InMemoryBackend) SetBlobSource

func (b *InMemoryBackend) SetBlobSource(s BlobSource)

SetBlobSource wires the in-process Blob Storage emulator used by azureblob data sources.

func (*InMemoryBackend) SetCosmosSource

func (b *InMemoryBackend) SetCosmosSource(s CosmosSource)

SetCosmosSource wires the in-process Cosmos DB emulator used by cosmosdb data sources.

func (*InMemoryBackend) SetKeyResolver

func (b *InMemoryBackend) SetKeyResolver(r KeyResolver)

SetKeyResolver wires the in-process Key Vault emulator used to resolve encryptionKey references.

func (*InMemoryBackend) SetSQLSource

func (b *InMemoryBackend) SetSQLSource(s SQLSource)

SetSQLSource wires the in-process Azure SQL emulator used by azuresql data sources.

func (*InMemoryBackend) SetTableSource

func (b *InMemoryBackend) SetTableSource(s TableSource)

SetTableSource wires the in-process Table Storage emulator used by azuretable data sources.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable.

func (*InMemoryBackend) WaitRuns

func (b *InMemoryBackend) WaitRuns()

WaitRuns blocks until every indexer run started on the default executor has finished.

type Index

type Index struct {
	Def  map[string]any  `json:"def"`
	Docs map[string]*Doc `json:"docs"`

	NextSeq int64 `json:"nextSeq"`
	// contains filtered or unexported fields
}

Index is a search index: its definition, documents and runtime caches.

type IndexerRuntime

type IndexerRuntime struct {
	Seen    map[string]string `json:"seen"`
	NextDue time.Time         `json:"nextDue"`
	Last    *RunResult        `json:"last,omitempty"`
	History []*RunResult      `json:"history"`
}

IndexerRuntime is the mutable state of an indexer.

type KeyResolver

type KeyResolver interface {
	ResolveKey(vaultName, keyName, version string) error
}

KeyResolver checks that a Key Vault key can be used for encryption: it exists and is enabled.

type Object

type Object = map[string]any

Object is a stored JSON resource (synonym map, data source, indexer, skillset).

type Option

type Option func(*InMemoryBackend)

Option customises a backend.

func WithClock

func WithClock(clock func() time.Time) Option

WithClock injects the clock used for timestamps and indexer schedules.

func WithIndexerExecutor

func WithIndexerExecutor(exec func(func())) Option

WithIndexerExecutor injects how indexer runs execute (default: a goroutine tracked by WaitRuns).

type Provider

type Provider struct{}

Provider implements service.Provider for Azure AI Search.

func (*Provider) Init

Init builds the backend and handler; the port is bound by Handler.StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type QueryKey

type QueryKey struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

QueryKey is a read-only key; Name may be empty.

type RunResult

type RunResult struct {
	StartTime      time.Time        `json:"startTime"`
	EndTime        time.Time        `json:"endTime"`
	Status         string           `json:"status"`
	ErrorMessage   string           `json:"errorMessage,omitempty"`
	Errors         []map[string]any `json:"errors"`
	Warnings       []map[string]any `json:"warnings"`
	ItemsProcessed int              `json:"itemsProcessed"`
	ItemsFailed    int              `json:"itemsFailed"`
}

RunResult is one indexer execution.

type SQLSource

type SQLSource interface {
	Query(ctx context.Context, server, database, text string) (cols []string, rows [][]string, err error)
}

SQLSource runs read-only queries on a server of the in-process Azure SQL emulator.

type Service

type Service struct {
	Created     time.Time                    `json:"created"`
	Indexes     map[string]*Index            `json:"indexes"`
	Objects     map[string]map[string]Object `json:"objects"`
	Runtime     map[string]*IndexerRuntime   `json:"runtime"`
	Name        string                       `json:"name"`
	Primary     string                       `json:"primary"`
	Secondary   string                       `json:"secondary"`
	QueryKeys   []QueryKey                   `json:"queryKeys"`
	Config      ServiceConfig                `json:"config"`
	NextETagSeq int64                        `json:"nextETagSeq"`
}

Service is one search service and everything it contains.

type ServiceConfig

type ServiceConfig struct {
	SKU                 string   `json:"sku"`
	HostingMode         string   `json:"hostingMode"`
	PublicNetworkAccess string   `json:"publicNetworkAccess"`
	AuthMode            string   `json:"authMode"`
	AADFailureMode      string   `json:"aadFailureMode,omitempty"`
	ResourceID          string   `json:"resourceId,omitempty"`
	CMKEnforcement      string   `json:"cmkEnforcement,omitempty"`
	IPRules             []string `json:"ipRules,omitempty"`
	ReplicaCount        int      `json:"replicaCount"`
	PartitionCount      int      `json:"partitionCount"`
	DisableLocalAuth    bool     `json:"disableLocalAuth,omitempty"`
}

ServiceConfig is the ARM-controlled configuration of a search service.

type Settings

type Settings struct {
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 254-byte string literal not displayed */
	ValidateTokens bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 254-byte string literal not displayed */
}

Settings is the Kong-embedded configuration of the Azure AI Search emulator.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider exists.

type TableEntity

type TableEntity struct {
	Timestamp    time.Time
	Properties   map[string]any
	PartitionKey string
	RowKey       string
	ETag         string
}

TableEntity is one entity of the in-process Table Storage emulator.

type TableSource

type TableSource interface {
	ListEntities(table, filter string) ([]TableEntity, error)
}

TableSource reads entities from the in-process Table Storage emulator; filter is an OData $filter or empty.

type Token

type Token struct {
	Term    string
	Pos     int
	Start   int
	End     int
	Keyword bool
}

Token is one analysed term with its position and byte offsets in the source text.

type TokenAuthority

type TokenAuthority interface {
	Authenticate(token string) (principalID string, err error)
	Allowed(principalID, resourceID, action string, data bool) bool
}

TokenAuthority validates Microsoft Entra bearer tokens and evaluates role assignments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL