Ultrahost/ docs

An index says which information is searchable. After that, application code indexes documents and queries them.

Paths in the tables are relative to https://api.ultrahost.com/v1/projects/{projectId}. Pagination, idempotency, and errors are described in Conventions.

Create

A search index tells Ultrahost which information your application needs to make searchable. Create an index, choose the fields to search, and start adding documents.

SDKRESTDescription
search.createIndex(name, config)POST /search/indexesCreate a search index
search.getIndex(name)GET /search/indexes/{name}Retrieve configuration
search.listIndexes()GET /search/indexesList indexes
search.updateIndex(name, config)PATCH /search/indexes/{name}Update settings
search.deleteIndex(name)DELETE /search/indexes/{name}Delete an index
ts
await ultrahost.search.createIndex("articles", config);

Creating an index is administrative. Querying it is application work, and the two can require different credentials. See Architecture.

Configure

Decide which fields matter when someone searches. You can rank titles above descriptions, add synonyms, or change how close a match must be.

SDKRESTDescription
search.configureFields(name, fields)PUT /search/indexes/{name}/fieldsConfigure searchable fields
search.configureSynonyms(name, synonyms)PUT /search/indexes/{name}/synonymsConfigure synonyms

Optional, and only when the index says they exist:

  • Analyzers and stemming
  • Ranking weights
  • Fuzzy matching
  • Phonetic search

Availability is part of index configuration and of projects.getCapabilities(). An application should not assume every analyzer exists on every deployment.

Use

Send a query and receive the most relevant documents, with optional highlights and filters.

SDKRESTDescription
search.index(name, document)POST /search/{name}/documentsIndex one document
search.indexBatch(name, documents)POST /search/{name}/documents/batchIndex many documents
search.remove(name, id)DELETE /search/{name}/documents/{id}Remove a document
search.query(name, query)POST /search/{name}/queryFull-text search
search.suggest(name, text)POST /search/{name}/suggestSuggestions
search.autocomplete(name, prefix)POST /search/{name}/autocompleteAutocomplete
search.facets(name, query)POST /search/{name}/facetsFacet counts
search.reindex(name)POST /search/{name}/reindexRebuild the index
ts
const results = await ultrahost.search.query("articles", {
  text: "refund policy",
  fields: ["title", "content"],
  highlight: true,
  limit: 10
});

reindex is long-running. It returns an operation. React search uses useSearch(index, query).