README

Lucius646/MoonSearch/query does not have a README file

#
Query

pub(open) trait Query {
fn weight(Self, SearchStatistics) -> &Weight
}

Describes matching intent and builds query-and-snapshot-specific state.

The trait is open so applications can add query types without changing Searcher. Concrete queries create one Weight from global SearchStatistics, and each Weight creates a comparable segment-local Scorer.

#
Scorer

pub(open) trait Scorer {
fn advance(Self) -> Bool
fn doc(Self) ->
DocId

fn score(Self) -> Double
}

Ordered iterator over matching segment-local documents and their scores.

#
Weight

pub(open) trait Weight {
fn scorer(Self,
Segment
) -> &Scorer
}

Query state that can create a Scorer for an immutable segment.

#
Bm25Scorer

pub struct Bm25Scorer {
field_id :
FieldId

idf : Double
average_length : Double
k1 : Double
b : Double
}

BM25 scorer using the common defaults k1=1.2 and b=0.75.

Query Weight implementations construct it from snapshot-wide statistics and use it while producing comparable segment-local Scorer results.

#
Bm25Scorer::from_statistics

fn Bm25Scorer::from_statistics(statistics : SearchStatistics, term :
Term
) -> Bm25Scorer

Builds query state from the complete Searcher snapshot.

#
Bm25Scorer::new

Builds single-Segment BM25 state. Retained for M1-M3 API compatibility.

#
BooleanClause

pub struct BooleanClause {
occur : Occur
query : &Query
}

One query and its occurrence rule in a BooleanQuery.

#
BooleanClause::new

fn BooleanClause::new(occur : Occur, query : &Query) -> BooleanClause

#
BooleanQuery

pub struct BooleanQuery {
clauses : ReadOnlyArray[BooleanClause]
}

#
BooleanQuery::new

#
BoostQuery

pub struct BoostQuery {
query : &Query
boost : Double
}

Multiplies every score produced by a child query.
impl Query for BoostQuery

#
BoostQuery::new

fn BoostQuery::new(query : &Query, boost : Double) -> BoostQuery

#
Occur

pub(all) enum Occur {
Must
Should
MustNot
} derive(Eq,
Debug
)

Boolean occurrence semantics modeled after Lucene and Tantivy.

#
PhraseQuery

pub struct PhraseQuery {
field_id :
FieldId

texts : ReadOnlyArray[String]
positions : ReadOnlyArray[Int]
}

Exact zero-slop phrase query within one field.

#
PhraseQuery::new

#
PhraseQuery::with_positions

fn PhraseQuery::with_positions(field_id :
FieldId
, texts : Array[String], positions : Array[Int]) -> PhraseQuery

Creates a phrase with explicit relative token positions, preserving gaps introduced during query-time analysis.

#
QueryParser

pub struct QueryParser {
schema :
Schema

tokenizers :
TokenizerManager

conjunction_by_default : Bool
}

Minimal field-aware query-time analysis. Query syntax parsing remains a separate concern; this type converts raw text into existing Query objects.

#
QueryParser::parse_phrase

Analyzes raw text and preserves analyzer positions in a PhraseQuery.

#
QueryParser::parse_query

Analyzes raw text and creates one TermQuery or a BooleanQuery. Multiple terms are disjunctive by default, matching Tantivy's default parser mode.

#
QueryParser::set_conjunction_by_default

fn QueryParser::set_conjunction_by_default(self : QueryParser, conjunction : Bool) -> Unit

#
SearchHit

pub(all) struct SearchHit {
address :
DocAddress

score : Double
} derive(
Debug
)

One scored document returned by a collector.

#
SearchStatistics

pub struct SearchStatistics {
segments : ReadOnlyArray[
SnapshotSegment
]
}

Read-only collection statistics for one Searcher snapshot.

Query implementations use these global values while constructing Weight. A Weight can then create comparable Scorers for every immutable Segment.

#
SearchStatistics::average_field_length

fn SearchStatistics::average_field_length(self : SearchStatistics, field_id :
FieldId
) -> Double

#
SearchStatistics::doc_count

fn SearchStatistics::doc_count(self : SearchStatistics) -> Int

#
SearchStatistics::document_frequency

fn SearchStatistics::document_frequency(self : SearchStatistics, term :
Term
) -> Int

#
SearchStatistics::field_doc_count

fn SearchStatistics::field_doc_count(self : SearchStatistics, field_id :
FieldId
) -> Int

#
SearchStatistics::segment_count

fn SearchStatistics::segment_count(self : SearchStatistics) -> Int

#
Searcher

pub struct Searcher {
segments : ReadOnlyArray[
SnapshotSegment
]
statistics : SearchStatistics
}

Stable read view over one immutable Segment set.

Searchers keep the exact Segment array and tombstones captured by their IndexReader generation. Later commits cannot mutate this view.

#
Searcher::doc

Loads a stored document from the Segment addressed by this snapshot.

#
Searcher::from_segments

fn Searcher::from_segments(segments : ReadOnlyArray[
SnapshotSegment
]) -> Searcher

#
Searcher::new

Creates a Searcher for one in-memory Segment.

#
Searcher::search

fn Searcher::search(self : Searcher, query : &Query, collector : TopKCollector) -> ReadOnlyArray[SearchHit]

Builds one Weight from snapshot-wide statistics, runs a Scorer against every Segment, then performs one global Top-K selection.

#
Searcher::segment_count

fn Searcher::segment_count(self : Searcher) -> Int

#
TermQuery

pub struct TermQuery {
term :
Term

}

Exact field-qualified term query.

The term is already analyzed. QueryParser is the higher-level entry point for raw field text; callers can keep using TermQuery for exact control.
impl Query for TermQuery

#
TopKCollector

pub struct TopKCollector {
limit : Int
}

Collector that retains at most the highest-scoring K documents.

#
TopKCollector::new

fn TopKCollector::new(limit : Int) -> TopKCollector

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io