luci/lib.rs
1// Obsidian [[wikilinks]] in doc comments are intentional — they link to
2// design and reference docs in docs/. Rustdoc doesn't understand them.
3#![allow(rustdoc::broken_intra_doc_links)]
4
5//! `luci` — embeddable, in-process search engine.
6//!
7//! The SQLite/DuckDB of Elasticsearch: link it in, open a file, search.
8//! Indexing JSON documents, term/BM25/vector search, segment merge, and
9//! persistence all live in this one crate, organized into modules that
10//! mirror the former workspace crates (`core`, `mapping`, `storage`,
11//! `analysis`) plus the engine subsystems.
12//!
13//! See [[luci|engineering vision]], [[architecture-overview]], and
14//! [[architecture-segment-layout]] for the design.
15
16// Former leaf crates, now modules.
17pub mod analysis;
18pub mod core;
19pub mod mapping;
20pub mod storage;
21
22// Engine subsystems (formerly luci-index).
23pub mod agg;
24pub mod columnar;
25pub mod inverted;
26pub mod ip;
27pub mod query;
28pub mod search;
29pub mod segment;
30pub mod spatial;
31pub mod store;
32pub mod vector;
33
34pub mod deletion;
35pub mod index;
36pub mod merge;
37pub mod merge_policy;
38pub mod reader;
39pub mod writer;
40
41// Top-level re-exports for the high-frequency API surface, so the common
42// types stay one path deep (`luci::Index`, `luci::Mapping`, `luci::LuciError`).
43pub use crate::core::{
44 DocId, FieldId, LuciError, Result, ScoreMode, Scorer, SegmentId, TwoPhaseIterator,
45};
46pub use crate::index::Index;
47pub use crate::mapping::{
48 DynamicMode, FieldMapping, FieldType, Mapping, MappingBuilder, QuantizationType,
49};
50
51/// Configure the global thread pool for parallel search.
52///
53/// Must be called before any search operation. Can only be called once
54/// per process — subsequent calls return an error.
55///
56/// If not called, rayon defaults to the number of available CPUs
57/// (or the `RAYON_NUM_THREADS` environment variable).
58pub fn set_num_threads(num_threads: usize) -> Result<()> {
59 rayon::ThreadPoolBuilder::new()
60 .num_threads(num_threads)
61 .build_global()
62 .map_err(|e| LuciError::InvalidQuery(format!("failed to set thread pool: {e}")))
63}