Expand description
Serverless autocompletion: exact, prefix, infix, abbreviation, spelling-tolerant, word-decomposing
and semantic completions over immutable, memory-mapped segments. With the store feature,
Database adds versioned storage on local disk, S3, GCS or Azure.
use std::sync::Arc;
use completype::{AliasKind, Document, Index, IndexOptions, MatchKind, Segment};
let docs = [
Document::new(1, "Under the Bridge – Red Hot Chili Peppers", 0.75)
.with_alias("RHCP", AliasKind::Abbreviation),
Document::new(2, "Bohemian Rhapsody – Queen", 0.95),
];
let index = Index::new(vec![Arc::new(Segment::build(docs, [])?)], IndexOptions::default())?;
let hits = index.complete("rhcp", 10);
assert_eq!((hits[0].id, hits[0].kind), (1, MatchKind::Abbreviation));Structs§
- Alias
- Alias
Suggestion - A document found through one of its synonyms.
- Blocking
Store Storefor synchronous callers, run on an internal runtime. Do not call from async code.- Build
Options - Build-time parameters. All segments of one index must share them. Set them with the chainable
methods of the same names, e.g.
BuildOptions::default().vector_bits(2). - Change
Set - Changes to one or more indexes, applied together and in submission order relative to other change sets. Later change sets win per document id.
- Cleanup
Policy - Cleanup
Stats - Client
- A database and the collections in it.
- Client
Namespace - The collections of one namespace.
- Collection
- Named documents to complete: add, delete and query them.
- Collection
Stats - A collection’s size and freshness.
- Compaction
Policy - Completion
- One completion, from whichever collection of the query’s layers decided it.
- Connect
Options - How a client connects and follows its database.
- Database
- Named indexes in named namespaces, stored under one store prefix.
- Database
Namespace - One namespace of a
Database: its transactions, indexes and compaction. - Document
- One completable entry: its id, display text, popularity, alternative names and contexts.
- Engine
- Named namespaces of named indexes, each published atomically and searched lock-free.
- Follow
Status - Follower
- Keeps an engine on its replica’s latest version from a background thread, until dropped.
- Hybrid
Options - Hybrid
Suggestion - A fused result.
kindis the lexical match kind when the document matched lexically, otherwiseMatchKind::Semantic. - Index
- An immutable, searchable view over segments ordered oldest to newest.
- Index
Entry - Index
Options - Options for searching segments as one index. Set them with the chainable methods of the same
names, e.g.
IndexOptions::default().max_score(742.0). - Ingestor
- Drains the inbox while holding the ingestor lease; run one per process, and whichever holds the lease ingests. Commits are fenced by the lease generation.
- Layered
Suggestion - Lease
- An advisory, expiring lock, e.g. to run one writer or compactor at a time.
- Manifest
- The full state of a database at one version. Version 0 is the empty database and has no file.
- Namespace
- One version of one namespace, searched in layers. Every search through it sees that version, however the engine changes meanwhile.
- Namespace
Changes - The changes of a
ChangeSetin one namespace. - Namespace
Transaction - Index operations of a
Transactionin one namespace. - Object
Info - Query
- What a query asks for, beyond its text.
- Replica
- Keeps an
Engineon the latest version of a database, loading only segments it lacks and switching each namespace to its new indexes in one step, one namespace at a time. - Search
Options - Per-request options: how many results, and which contexts they must be tagged with.
- Segment
- An immutable batch of documents plus the ids it deletes from older segments.
- Segment
Builder - Collects documents compactly, then builds one segment from them, in memory or into a file.
- Segment
Ref - Segment
Writer - Writes documents into segment files in a directory, starting a new segment before the build of the current one would need more than the memory budget, as tantivy flushes a segment when its writer’s budget fills. An index of the segments ranks exactly like one segment, and of several documents with one id, the last added wins.
- Store
- Async access to one prefix of an object store. Keys are
/-separated and relative to it. - Suggestion
- One completion: the document, how it matched, and which parts of its text matched.
- Transaction
- Changes staged against one manifest and committed together.
Enums§
- Alias
Kind - Error
- Fusion
- How lexical and semantic results are combined.
- Ingest
Step - What one ingestor round did.
- Match
Kind - Optimize
- When a collection compacts its segments.
Constants§
- BASE_
LEVEL - Level of a segment written by an overwrite or a full compaction; tiered compaction skips it.
- DEFAULT_
NAMESPACE - The namespace of indexes published or written without naming one.
Functions§
- block_
on - Runs a future to completion on completype’s internal runtime. Do not call from async code.
- connect
- Opens the database at
url: a local directory,memory://,s3://,gs://oraz://. - key_id
- The numeric id of a string key: a stable 64-bit hash, so any process derives the same id.
- layered_
complete - With more than one layer, each is asked for
limit * overfetchsuggestions before merging. - layered_
complete_ aliases