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
- Variables
- type AdminKeys
- type Analyzer
- type BlobEntry
- type BlobSource
- type ConfigProvider
- type CosmosDoc
- type CosmosSource
- type Doc
- type Handler
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) CreateQueryKey(name, keyName string) (QueryKey, error)
- func (b *InMemoryBackend) DeleteQueryKey(name, key string) error
- func (b *InMemoryBackend) DeleteService(name string) error
- func (b *InMemoryBackend) EncryptionCompliance(name string) string
- func (b *InMemoryBackend) HasService(name string) bool
- func (b *InMemoryBackend) Keys(name string) (AdminKeys, error)
- func (b *InMemoryBackend) ListQueryKeys(name string) ([]QueryKey, error)
- func (b *InMemoryBackend) PutService(name string, cfg ServiceConfig) (time.Time, error)
- func (b *InMemoryBackend) RegenerateAdminKey(name, kind string) (AdminKeys, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) ResetIndexer(service, name string) error
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RunDue() int
- func (b *InMemoryBackend) RunIndexer(service, name string) error
- func (b *InMemoryBackend) ServiceNames() []string
- func (b *InMemoryBackend) SetBlobSource(s BlobSource)
- func (b *InMemoryBackend) SetCosmosSource(s CosmosSource)
- func (b *InMemoryBackend) SetKeyResolver(r KeyResolver)
- func (b *InMemoryBackend) SetSQLSource(s SQLSource)
- func (b *InMemoryBackend) SetTableSource(s TableSource)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) WaitRuns()
- type Index
- type IndexerRuntime
- type KeyResolver
- type Object
- type Option
- type Provider
- type QueryKey
- type RunResult
- type SQLSource
- type Service
- type ServiceConfig
- type Settings
- type TableEntity
- type TableSource
- type Token
- type TokenAuthority
Constants ¶
const DefaultPollInterval = 30 * time.Second
DefaultPollInterval is how often the indexer scheduler checks for due schedules.
const DefaultPort = 10015
DefaultPort is the Azure AI Search data-plane HTTPS port.
Variables ¶
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") 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.
ErrSourceUnavailable is returned when no in-process data source emulator is wired.
Functions ¶
This section is empty.
Types ¶
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 CosmosSource ¶
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 ¶
ExtractOperation implements service.Service.
func (*Handler) ExtractResource ¶
ExtractResource implements service.Service.
func (*Handler) GetSupportedOperations ¶
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 ¶
MatchPriority implements service.Registerable.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Azure AI Search listens on its own port.
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) 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 ¶
KeyResolver checks that a Key Vault key can be used for encryption: it exists and is enabled.
type Option ¶
type Option func(*InMemoryBackend)
Option customises a backend.
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 ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler; the port is bound by Handler.StartWorker.
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.
Source Files
¶
- analysis.go
- analysis_custom.go
- analysis_defs.go
- analysis_more.go
- auth.go
- backend.go
- cmk.go
- compile.go
- consts.go
- debug.go
- docs.go
- enrich.go
- enrich_expr.go
- errors.go
- facets.go
- filter.go
- handler.go
- highlight.go
- indexers.go
- indexops.go
- ipaccess.go
- markdown.go
- model.go
- objects.go
- ops.go
- orderby.go
- ordered.go
- persistence.go
- provider.go
- queryexec.go
- queryparse.go
- routes.go
- scoring.go
- search.go
- searchreq.go
- searchresp.go
- server.go
- settings.go
- sources.go
- sqlsource.go
- stats.go
- suggest.go
- synonyms.go
- values.go
- vector.go
- vectorcfg.go
- vectorize.go