Crates.io | searchy |
lib.rs | searchy |
version | 0.5.0 |
source | src |
created_at | 2022-05-27 21:36:43.67393 |
updated_at | 2024-11-11 19:24:31.689854 |
description | Search index (in-memory), that can be constructed and searched using a bag of words model, with cosine similarity scoring based on tf-idf. Supports multiple search terms, permissions, text suggestions (for spelling errors), and evaluating common arithmetic expressions directly to values. Tries to reduce memory footprint. |
homepage | https://www.bitpowder.com/libs/indigo/ |
repository | https://gitlab.com/bitpowder/indigo-ng |
max_upload_size | |
id | 595327 |
size | 63,779 |
Search index (in-memory), that can be constructed and searched using a bag of words model, with cosine similarity scoring based on tf-idf. Supports multiple search terms, permissions, text suggestions (for spelling errors), and evaluating common arithmetic expressions directly to values. Tries to reduce memory footprint.
Features:
use searchy::*;
use expry::*;
// MemoryPool avoids small allocations.
pool!(scope);
// Add documents
let mut builder = SearchBuilder::new();
let doc_id = builder.add_document("foo bar text", "url", "name", "group1", b"extra", &mut scope);
// doc_id can be used to later remove the document from the search index
// Build search index
let index : SearchIndex = builder.into();
// Roles are access groups of the user. The search documents have access groups and are are filtered based on the access group of the current user.
const MAX_DOCS_RETRIEVED : usize = 1024;
let results = index.search("query text", "group1,group2", MAX_DOCS_RETRIEVED);
eprintln!("RESULTS: {}x/{} in {}ms", results.docs, results.more, results.duration);
for ScoredDocumentInfo{doc_id: _, score, info} in results.entries {
eprintln!("{} -> {}, {}, {}", score, info.name, info.url, info.summary);
}
// do some mutations to the search index
let mut builder = SearchBuilder::from(index);
builder.remove_document(doc_id);