Index a document's text content.
(
&self,
tid: TenantId,
collection: &str,
surrogate: Surrogate,
text: &str,
)
| 21 | impl 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( |