
# Enums

Enumeration types used for configuration and mode selection in `TextIndex<T>`.

---

## SearchMode

Selects which search engine(s) to use in the unified `search()` method.

```gcl
enum SearchMode {
    hybrid;
    bm25;
    semantic;
    exact;
    fuzzy;
    boolean;
    proximity;
    phrase;
    prefix;
    wildcard;
    span;
    dfr;
    lm_dirichlet;
    phonetic;
    quorum;
}
```

| Value | Description |
|-------|-------------|
| `hybrid` | Default hybrid mode combining BM25 + exact + fuzzy (+ semantic when `config.embed` is set) |
| `bm25` | BM25 probabilistic ranking |
| `semantic` | Vector similarity via embeddings (requires AI library) |
| `exact` | Normalized substring matching |
| `fuzzy` | Levenshtein distance fuzzy matching |
| `boolean` | Boolean query with AND/OR/NOT operators |
| `proximity` | Two-term distance-based scoring |
| `phrase` | Exact phrase matching with positional verification |
| `prefix` | Prefix-based term matching |
| `wildcard` | Wildcard pattern matching (`*` and `?`) |
| `span` | Positional span queries (NEAR/ONEAR/FIRST) |
| `dfr` | Divergence From Randomness scoring |
| `lm_dirichlet` | Language Model with Dirichlet smoothing |
| `phonetic` | Phonetic matching (Double Metaphone) |
| `quorum` | Minimum-should-match queries |

**Usage**

```gcl
// Single mode
var modes = Array<SearchMode> {};
modes.add(SearchMode::bm25);
var _options = SearchOptions { modes: modes };

// Multi-mode fusion
var modes2 = Array<SearchMode> {};
modes2.add(SearchMode::bm25);
modes2.add(SearchMode::phrase);
var _options2 = SearchOptions { modes: modes2 };
```

---

## FuzzyMode

Selects how a fuzzy search matches against the index. Used inside `FuzzyOptions`.

```gcl
enum FuzzyMode {
    key;
    term;
}
```

| Value | Description |
|-------|-------------|
| `key` | Match whole document keys against the query (Levenshtein on full strings). Default. |
| `term` | Match individual query terms against the vocabulary (per-token fuzzy). |

**Usage**

```gcl
var modes = Array<SearchMode> {};
modes.add(SearchMode::fuzzy);

var _options = SearchOptions {
    modes: modes,
    fuzzy: FuzzyOptions { mode: FuzzyMode::term, maxEdits: 1 }
};
```

---

## StopWordMode

Controls how stop words are handled during indexing.

```gcl
enum StopWordMode {
    none;
    auto;
    default;
    custom;
}
```

| Value | Description |
|-------|-------------|
| `none` | No stop word filtering |
| `auto` | Auto-detect stop words by document frequency threshold |
| `default` | Use built-in stop word list for the configured language |
| `custom` | Use a custom stop word list provided in config |

---

## BM25Variant

Selects the BM25 scoring formula variant.

```gcl
enum BM25Variant {
    lucene;
    plus;
    bm25l;
    atire;
    robertson;
}
```

| Value | Description |
|-------|-------------|
| `lucene` | Lucene variant with IDF = `log(1 + (N - df + 0.5) / (df + 0.5))` (always positive) |
| `plus` | BM25+ variant with lower-bound term frequency guarantee |
| `bm25l` | BM25L variant with boosted long-document handling |
| `atire` | ATIRE variant |
| `robertson` | Original Robertson BM25 formulation |

---

## BooleanOperator

Internal enum used by `BooleanParser` to represent parsed boolean operators. Users do not interact with this enum directly -- boolean queries are written as strings (e.g., `"machine AND learning NOT survey"`) and parsed automatically.

```gcl
enum BooleanOperator {
    AND;
    OR;
    NOT;
    WEAKAND;
}
```

| Value | Description |
|-------|-------------|
| `AND` | All operands must match |
| `OR` | Any operand may match |
| `NOT` | Exclude matching documents |
| `WEAKAND` | At least N of the listed terms must match (minimum-should-match) |

---

## FusionMethod

Score fusion strategy for combining results from multiple search modes.

```gcl
enum FusionMethod {
    rrf;
    linear;
}
```

| Value | Description |
|-------|-------------|
| `rrf` | Reciprocal Rank Fusion -- rank-based, parameter-light |
| `linear` | Linear weighted combination of normalized scores |

---

## Normalization

Score normalization method applied before fusion.

```gcl
enum Normalization {
    minmax;
    zscore;
}
```

| Value | Description |
|-------|-------------|
| `minmax` | Min-max normalization to [0, 1] range |
| `zscore` | Z-score normalization (mean = 0, std = 1) |

---

## ChunkStrategy

Strategy for splitting long documents into chunks (used with semantic search).

```gcl
enum ChunkStrategy {
    none;
    fixed;
    sentence;
    paragraph;
    recursive;
}
```

| Value | Description |
|-------|-------------|
| `none` | No chunking -- index whole document |
| `fixed` | Fixed word-count chunks (`chunking.size` words, `chunking.overlap` words of overlap) |
| `sentence` | Split on sentence boundaries |
| `paragraph` | Split on paragraph boundaries |
| `recursive` | Recursive splitting (paragraph -> sentence -> fixed) |

---

## TextSearchLanguage

Language selection for stop words and stemming. 33 supported languages.

```gcl
enum TextSearchLanguage {
    ar; bg; ca; cs; da; de; el; en; es; fa; fi; fr; gu; he; hi; hu;
    id; it; ja; ko; ms; nl; no; pl; pt; ro; ru; sk; sv; tr; uk; vi; zh;
}
```

| Code | Language | Code | Language | Code | Language |
|------|----------|------|----------|------|----------|
| `ar` | Arabic | `he` | Hebrew | `pl` | Polish |
| `bg` | Bulgarian | `hi` | Hindi | `pt` | Portuguese |
| `ca` | Catalan | `hu` | Hungarian | `ro` | Romanian |
| `cs` | Czech | `id` | Indonesian | `ru` | Russian |
| `da` | Danish | `it` | Italian | `sk` | Slovak |
| `de` | German | `ja` | Japanese | `sv` | Swedish |
| `el` | Greek | `ko` | Korean | `tr` | Turkish |
| `en` | English | `ms` | Malay | `uk` | Ukrainian |
| `es` | Spanish | `nl` | Dutch | `vi` | Vietnamese |
| `fa` | Persian | `no` | Norwegian | `zh` | Chinese |
| `fi` | Finnish | | | | |
| `fr` | French | | | | |
| `gu` | Gujarati | | | | |

---

## DFRBasicModel

Basic information model for DFR (Divergence From Randomness) scoring.

```gcl
enum DFRBasicModel {
    G;
    In;
    Ine;
    IF;
}
```

| Value | Description |
|-------|-------------|
| `G` | Geometric approximation of Bose-Einstein model |
| `In` | Inverse document frequency model (tf-weighted) |
| `Ine` | Inverse expected document frequency (normalized) |
| `IF` | Inverse term frequency model |

---

## DFRAfterEffect

After-effect model for normalizing information gain in DFR scoring.

```gcl
enum DFRAfterEffect {
    Laplace;
    Bernoulli;
}
```

| Value | Description |
|-------|-------------|
| `Laplace` | Laplace succession: `1 / (tf + 1)` |
| `Bernoulli` | Bernoulli smoothing based on average document length |

---

## DFRNormalization

Normalization component for document length adjustment in DFR scoring.

```gcl
enum DFRNormalization {
    H1;
    H2;
    H3;
    Z;
}
```

| Value | Description |
|-------|-------------|
| `H1` | Pivoted length normalization |
| `H2` | Logarithmic length normalization |
| `H3` | Dirichlet-style length normalization |
| `Z` | Bounded length normalization |

---

## RankingRule

Ranking rules for Meilisearch-style multi-factor ranking.

```gcl
enum RankingRule {
    words;
    typo;
    proximity;
    attribute;
    sort;
    exactness;
}
```

| Value | Description |
|-------|-------------|
| `words` | Number of matching words (descending) |
| `typo` | Number of typos (ascending -- fewer typos = better) |
| `proximity` | Proximity between query terms in document (ascending -- closer = better) |
| `attribute` | Position of first matched term (ascending -- earlier = better) |
| `sort` | Custom sort field value |
| `exactness` | Exact match priority (descending) |

---

## FacetType

Type of facet aggregation.

```gcl
enum FacetType {
    term;
    numericRange;
}
```

| Value | Description |
|-------|-------------|
| `term` | Count documents by distinct string field values |
| `numericRange` | Count documents in numeric ranges |

---

## MetricType

Metric aggregation type for search result analytics.

```gcl
enum MetricType {
    sum;
    avg;
    min;
    max;
    cardinality;
}
```

| Value | Description |
|-------|-------------|
| `sum` | Sum of numeric values |
| `avg` | Average of numeric values |
| `min` | Minimum numeric value |
| `max` | Maximum numeric value |
| `cardinality` | Count of distinct values |

---

## DecayType

Decay function type for function scoring.

```gcl
enum DecayType {
    gaussian;
    linear;
    exponential;
}
```

| Value | Description |
|-------|-------------|
| `gaussian` | Gaussian (bell curve) decay: `exp(ln(decay) * (distance/scale)^2)` — calibrated so that `distance == scale` yields the configured `decay` value (default 0.5) |
| `linear` | Linear decay: `max(0, 1 - distance/scale)` |
| `exponential` | Exponential decay: `exp(ln(decay) * distance/scale)` — calibrated so that `distance == scale` yields the configured `decay` value (default 0.5) |

---

## SpanOperator

Span query operator types for positional queries.

```gcl
enum SpanOperator {
    NEAR;
    ONEAR;
    FIRST;
    TERM;
}
```

| Value | Description |
|-------|-------------|
| `NEAR` | Unordered proximity match -- both terms within N positions |
| `ONEAR` | Ordered proximity match -- term1 before term2 within N positions |
| `FIRST` | First-N-tokens window match -- term appears in first N positions |
| `TERM` | Leaf term node (internal use) |

---

## PercolateMode

Matching mode for percolate (reverse search) queries.

```gcl
enum PercolateMode {
    bm25;
    boolean;
}
```

| Value | Description |
|-------|-------------|
| `bm25` | Any-term match -- at least one query term must appear in the document |
| `boolean` | Boolean logic -- supports AND/OR operators for term matching |

**Usage**

```gcl
percolator.add_query("alert1", "machine learning", PercolateMode::bm25);
percolator.add_query("alert2", "security AND vulnerability", PercolateMode::boolean);
```

---

## FieldModifier

Modifier functions for field value factors in function scoring.

```gcl
enum FieldModifier {
    none;
    log;
    log1p;
    sqrt;
    square;
}
```

| Value | Description |
|-------|-------------|
| `none` | No modification -- use raw value |
| `log` | Natural logarithm: `log(x)` |
| `log1p` | Natural logarithm of `1 + x`: `log(1 + x)` |
| `sqrt` | Square root: `sqrt(x)` |
| `square` | Square: `x * x` |

---

## ScoreMode

Score combination modes for function scoring -- controls how multiple function scores are combined.

```gcl
enum ScoreMode {
    multiply;
    sum;
    avg;
    max;
    min;
}
```

| Value | Description |
|-------|-------------|
| `multiply` | Multiply all function scores (default) |
| `sum` | Sum all function scores |
| `avg` | Average of all function scores |
| `max` | Take the maximum function score |
| `min` | Take the minimum function score |

---

## BoostMode

Boost combination modes for function scoring -- controls how the combined function score is merged with the base relevance score.

```gcl
enum BoostMode {
    multiply;
    sum;
    replace;
}
```

| Value | Description |
|-------|-------------|
| `multiply` | Multiply base score by function score (default) |
| `sum` | Add function score to base score |
| `replace` | Replace base score with function score |

---

## SectionType

Type classification for document sections.

```gcl
enum SectionType {
    paragraph;
    heading;
    table;
    code;
    list;
    blockquote;
    horizontalRule;
}
```

| Value | Description |
|-------|-------------|
| `paragraph` | Regular paragraph text |
| `heading` | Section heading |
| `table` | Table content |
| `code` | Code block |
| `list` | List (ordered or unordered) |
| `blockquote` | Block quote |
| `horizontalRule` | Horizontal rule / separator |
