Skip to main content

writerslogic_warm/core/
documents.rs

1// Copyright 2024-2026 WritersLogic Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4use anyhow::{bail, ensure, Result};
5use serde::{Deserialize, Serialize};
6use serde_json::Value;
7use std::collections::BTreeMap;
8use std::ops::Deref;
9use std::sync::{Arc, OnceLock};
10
11use super::{encoding::TextEncoder, entangled::EntangledHVec};
12
13pub(crate) mod binary;
14#[cfg(test)]
15mod compact_term_tests;
16mod packed_terms;
17use packed_terms::StoredTerms;
18
19pub mod analysis;
20#[cfg(test)]
21mod census;
22mod dense;
23mod image;
24mod impact;
25mod lists;
26mod screen;
27pub use analysis::Analyzer;
28mod index;
29mod lexical;
30mod listing;
31mod memory;
32#[cfg(test)]
33mod multilingual_tests;
34mod overlay;
35mod positions;
36mod postings;
37mod reorder;
38mod search;
39mod text;
40mod text_blocks;
41#[cfg(not(target_arch = "wasm32"))]
42mod vector_index;
43pub(crate) use dense::{build_dense_index, capture_dense_index, publish_dense_index};
44pub(crate) use image::{
45    binding as checkpoint_binding, known_magic as checkpoint_magic_known,
46    recorded_crc as checkpoint_crc, representable as checkpoint_representable, Backing,
47    ServingImage, CRC_START as CHECKPOINT_CRC_START, HEADER_LEN as CHECKPOINT_HEADER_LEN,
48};
49pub(crate) use index::DocumentWithText;
50pub(crate) use index::{canonical_staging_path, opaque_counter_start, DocumentStore};
51pub(crate) use lexical::execute as execute_lexical;
52pub(crate) use lexical::plain_search as plain_lexical_search;
53pub(crate) use lexical::served as served_lexical;
54pub use lexical::{LexicalExecution, LexicalHit, LexicalOptions, LexicalQuery, LexicalResults};
55pub(crate) use listing::{
56    capture_chunk, count, get_info, get_record, list_info, list_records, CapturedDocumentRead,
57};
58pub use listing::{DocumentChunkRecord, DocumentInfo, DocumentReadChanged, DocumentRecord};
59pub use memory::{MemoryDocumentStore, MemoryStoreStats};
60pub(crate) use overlay::Base as CheckpointBase;
61#[cfg(test)]
62pub(crate) use search::prepare_search;
63pub(crate) use search::{
64    capture_search, count_matches, execute_search, prepare_search_with, rank_search, read_ranked,
65    validate_search, CapturedSearch, PreparedSearch,
66};
67pub(crate) use text::TextSegment;
68#[cfg(not(target_arch = "wasm32"))]
69pub(crate) use vector_index::{
70    build_configured_vector_snapshot, capture_vector_rows, search_vector_snapshot_with_report,
71    vector_index_status, VectorIndexSlot,
72};
73#[cfg(all(test, not(target_arch = "wasm32")))]
74pub(crate) use vector_index::{rank_vector_snapshot, read_vector_hits};
75#[cfg(not(target_arch = "wasm32"))]
76pub use vector_index::{
77    GraphUnavailable, VectorCandidateIdentity, VectorIndex, VectorIndexKind, VectorIndexMode,
78    VectorIndexStatus, VectorQueryOptions, VectorSearchDiagnostics, VectorSearchResults,
79    VectorSearchRoute, DEFAULT_EF, DEFAULT_GRAPH_MIN_ROWS, MAX_EF, MAX_K, REBUILD_AFTER_MUTATIONS,
80    SNAPSHOT_MIN_ROWS,
81};
82
83/// [`capture_search`] over the checkpoint under `store` and the store's own documents, for
84/// queries [`overlay_serves`] accepts.
85#[cfg(test)]
86pub(crate) use image::encode_v1 as encode_checkpoint_v1;
87
88mod chunking;
89#[cfg(test)]
90mod cosine_batch_tests;
91mod embedding;
92mod prepare;
93mod query;
94mod stored;
95mod terms;
96#[cfg(test)]
97mod tests;
98mod types;
99pub use self::chunking::*;
100pub(crate) use self::embedding::*;
101pub(crate) use self::prepare::*;
102pub(crate) use self::query::*;
103pub(crate) use self::stored::*;
104pub(crate) use self::terms::*;
105pub use self::types::*;