MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / index_document

Method index_document

nodedb/src/engine/sparse/inverted/indexing.rs:23–42  ·  view source on GitHub ↗

Index a document's text content.

(
        &self,
        tid: TenantId,
        collection: &str,
        surrogate: Surrogate,
        text: &str,
    )

Source from the content-addressed store, hash-verified

21impl InvertedIndex {
22 /// Index a document's text content.
23 pub fn index_document(
24 &self,
25 tid: TenantId,
26 collection: &str,
27 surrogate: Surrogate,
28 text: &str,
29 ) -> crate::Result<()> {
30 let tokens = nodedb_fts::analyze(text);
31 if tokens.is_empty() {
32 return Ok(());
33 }
34
35 let db = self.inner.backend().db();
36 let write_txn = db.begin_write().map_err(|e| inverted_err("write txn", e))?;
37 self.write_index_data(&write_txn, tid, collection, surrogate, &tokens)?;
38 write_txn
39 .commit()
40 .map_err(|e| inverted_err("commit index", e))?;
41 Ok(())
42 }
43
44 /// Index a document within an externally-owned write transaction.
45 pub fn index_document_in_txn(

Callers 7

index_and_searchFunction · 0.45
search_with_stemmingFunction · 0.45
fuzzy_searchFunction · 0.45
remove_documentFunction · 0.45
empty_queryFunction · 0.45
collections_isolatedFunction · 0.45

Calls 8

inverted_errFunction · 0.85
begin_writeMethod · 0.80
write_index_dataMethod · 0.80
analyzeFunction · 0.50
is_emptyMethod · 0.45
dbMethod · 0.45
backendMethod · 0.45
commitMethod · 0.45

Tested by 7

index_and_searchFunction · 0.36
search_with_stemmingFunction · 0.36
fuzzy_searchFunction · 0.36
remove_documentFunction · 0.36
empty_queryFunction · 0.36
collections_isolatedFunction · 0.36