Skip to main content

Crate completype

Crate completype 

Source
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
AliasSuggestion
A document found through one of its synonyms.
BlockingStore
Store for synchronous callers, run on an internal runtime. Do not call from async code.
BuildOptions
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).
ChangeSet
Changes to one or more indexes, applied together and in submission order relative to other change sets. Later change sets win per document id.
CleanupPolicy
CleanupStats
Client
A database and the collections in it.
ClientNamespace
The collections of one namespace.
Collection
Named documents to complete: add, delete and query them.
CollectionStats
A collection’s size and freshness.
CompactionPolicy
Completion
One completion, from whichever collection of the query’s layers decided it.
ConnectOptions
How a client connects and follows its database.
Database
Named indexes in named namespaces, stored under one store prefix.
DatabaseNamespace
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.
FollowStatus
Follower
Keeps an engine on its replica’s latest version from a background thread, until dropped.
HybridOptions
HybridSuggestion
A fused result. kind is the lexical match kind when the document matched lexically, otherwise MatchKind::Semantic.
Index
An immutable, searchable view over segments ordered oldest to newest.
IndexEntry
IndexOptions
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.
LayeredSuggestion
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.
NamespaceChanges
The changes of a ChangeSet in one namespace.
NamespaceTransaction
Index operations of a Transaction in one namespace.
ObjectInfo
Query
What a query asks for, beyond its text.
Replica
Keeps an Engine on 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.
SearchOptions
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.
SegmentBuilder
Collects documents compactly, then builds one segment from them, in memory or into a file.
SegmentRef
SegmentWriter
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§

AliasKind
Error
Fusion
How lexical and semantic results are combined.
IngestStep
What one ingestor round did.
MatchKind
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:// or az://.
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 * overfetch suggestions before merging.
layered_complete_aliases