Discovery / fast retrieval
P1 · Intelligence
Search Engine
Make application content discoverable with full-text search, ranking, filtering, and configurable text analysis.
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.
| SDK | REST | Description |
|---|---|---|
search.createIndex(name, config) | POST /search/indexes | Create a search index |
search.getIndex(name) | GET /search/indexes/{name} | Retrieve configuration |
search.listIndexes() | GET /search/indexes | List indexes |
search.updateIndex(name, config) | PATCH /search/indexes/{name} | Update settings |
search.deleteIndex(name) | DELETE /search/indexes/{name} | Delete an index |
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.
| SDK | REST | Description |
|---|---|---|
search.configureFields(name, fields) | PUT /search/indexes/{name}/fields | Configure searchable fields |
search.configureSynonyms(name, synonyms) | PUT /search/indexes/{name}/synonyms | Configure 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.
| SDK | REST | Description |
|---|---|---|
search.index(name, document) | POST /search/{name}/documents | Index one document |
search.indexBatch(name, documents) | POST /search/{name}/documents/batch | Index many documents |
search.remove(name, id) | DELETE /search/{name}/documents/{id} | Remove a document |
search.query(name, query) | POST /search/{name}/query | Full-text search |
search.suggest(name, text) | POST /search/{name}/suggest | Suggestions |
search.autocomplete(name, prefix) | POST /search/{name}/autocomplete | Autocomplete |
search.facets(name, query) | POST /search/{name}/facets | Facet counts |
search.reindex(name) | POST /search/{name}/reindex | Rebuild the index |
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).