> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust SDK Search Configuration

> cognee-rust settings for search, the triplet and hybrid retrievers, search history, and the improve loop with feedback and personalization.

Every value here resolves as `defaults < config.json < .env < env < code`
([precedence](https://docs.cognee.ai/rust/configuration.md#precedence)), and can be set from code with
the [config API](https://docs.cognee.ai/rust/configuration.md#runtime-configuration-api) or
[`cognee-cli config`](https://docs.cognee.ai/rust/configuration#cli-config-subcommand).

## Search

The `search` and `search.hybrid` engine sections tune the standard retrievers;
cognee hands them to `SearchBuilder::with_tuning` (`Settings::search_tuning`).

| Env var | Key (alias) | Default | Effect |
| - | - | - | - |
| `ALLOW_CYPHER_QUERY` | `search.allow_cypher_query` (`allow_cypher_query`) | `true` | `false` (or `0`/`no`/`off`) refuses the CYPHER and NATURAL\_LANGUAGE search types. Any other value is ignored with a warning and keeps them allowed. In a `.env` shared with Python cognee, an unset or unrecognized value allows them here but refuses them in Python, where the flag is off by default and only `true`, `1` or `yes` enable it. |
| `COGNEE_HYBRID_MAX_CONTEXT_TOKENS` | `search.hybrid.max_context_tokens` | *(unset — the LLM's context length)* | HYBRID\_COMPLETION and TEMPORAL context budget in tokens; `0` turns budgeting off. |
| `COGNEE_HYBRID_SUMMARIZE_OVERFLOW` | `search.hybrid.summarize_overflow` | `false` | Summarize passages that overflow the budget instead of dropping them. |
| `COGNEE_HYBRID_SUMMARIZE_BATCH` | `search.hybrid.summarize_batch` | `1` | Overflow passages per summarization call. |
| `COGNEE_HYBRID_OVERFLOW_SUMMARY_FILE` | `search.hybrid.overflow_summary_file` | *(empty)* | JSON object of precomputed overflow summaries (chunk id → summary). |

Four `Settings` fields tune the search orchestrator itself, lowered by the same
`Settings::search_tuning`:

| Env var | `Settings` field | Default | Effect |
| - | - | - | - |
| `ENABLE_LAST_ACCESSED` | `enable_last_accessed` | `false` | Update `last_accessed` on the source data records of every search's retrieved context. On a plain completion search the context is then fetched by the search itself and handed to the retriever, so it is still fetched once. `FEEDBACK` searches retrieve no data and are not tracked. `api::cleanup_unused_data` takes this flag's value as its `enable_last_accessed` argument and is skipped while it is `false`. |
| `AUTO_FEEDBACK` | `auto_feedback` | `true` | Analyze feedback, corrections, and follow-up queries in a session search when the request leaves `auto_feedback_detection` unset, and only while `session.caching` is on. The same switch gates improve's `extract_agent_context` stage (`auto_feedback_disabled` when off), the LLM summary of an agent trace step that asks for one (`generate_feedback_with_llm`; off stores the deterministic `"<origin> succeeded."` / `"<origin> failed. …"` line), and the agent-context extraction each stored trace step triggers (a `failure_lessons` entry per errored step that carries an error message; an LLM batch pass every `TRACE_EXTRACTION_INTERVAL` (10) steps; a failed pass is retried on the next trace write). It now defaults on; set it to `false` to avoid the extra structured-output LLM call per session turn and these trace-step LLM calls. Retrievers that opt out of session-turn preparation (chunks, lexical, summaries, Cypher, natural language, graph report, feedback) make no turn-analysis call, write no session feedback and record no QA row (a `FEEDBACK` search still makes its own LLM call and writes its `Feedback` graph node). Custom and community retrievers now prepare turns unless they override `SearchRetriever::supports_session_turn_preparation`; before, only the built-in completion types did. |
| `SESSION_SEARCH_MODE` | `session_search_mode` | `concurrent` | `concurrent` overlaps the session turn's analysis with retrieval and completion for the eligible built-in RAG, graph, and hybrid completion types; the analysis is bounded at 30 seconds and falls back to the raw query if the model does not return. `sequential` analyzes the turn first and retrieves with the rewritten effective query; a feedback-only turn is acknowledged without retrieval. Both keep the raw user message in session history, and both analyze the turn only while `AUTO_FEEDBACK` is on. A concurrent turn with history also retrieves a second time with a bounded conversational rewrite of the last two Q\&A turns (at most 2000 characters; skipped when it equals the raw question), and the retriever merges the two results under its own `top_k` limits. Other session completion types (temporal, the graph-completion variants), batch, feeling-lucky, and community searches take the sequential path, as does any search while the session cache is unavailable; previews (`only_context`) and batch searches run no turn analysis. A completion search with no `session_id` uses the [default session](https://docs.cognee.ai/rust/core-concepts/sessions-and-caching.md) when it has a user, its retriever prepares session turns, and session caching is on. Only the exact values `sequential` and `concurrent` are accepted (no trimming or case folding; earlier builds lowercased the value, so `Sequential` or `CONCURRENT` that used to work now fails): any other value is an error from `ConfigManager::set`, and from env it fails `ConfigManager::check_supported` / `check_strict`, which every component build runs, until the key is set or reset. |
| — | `default_system_prompt_path` | `answer_simple_question.txt` | System prompt file for a search that names neither a system prompt nor a prompt path. The default and an empty value leave each retriever's own compiled-in prompt; any other value is read as a file. |

## Triplet retriever hub cap

This caps the triplet search behind the graph completion types
(`brute_force_triplet_search`). It is unrelated to the `TRIPLET_COMPLETION`
search type, which has been removed.

| Env var | Key | Default | Effect |
| - | - | - | - |
| `COGNEE_TRIPLET_NEIGHBOR_CAP` | `search.triplet_neighbor_cap` | *(unset — uncapped)* | Per vector-search seed, keep every neighbour that is itself a seed plus at most `n` other neighbours (the smallest ids in byte order), then score the subgraph induced on what is kept. |

> [!WARNING]
>
> **Opt-in, and it changes results.** Unset — the default — the triplet retriever
> loads the full depth-1 neighbourhood of its seeds, which is result-identical to
> loading the whole graph. A cap truncates hub fan-out: edges from a hub seed to
> its dropped neighbours never reach the ranking. Those edges would carry the
> non-seed distance penalty and rank below seed-to-seed edges, but they could
> still have made the top *k*.

Measured on a synthetic 100k corpus, a cap of 100 keeps a Jaccard similarity of
0.93–0.96 against the uncapped result set, with a worst query at 0.67; a cap of
200 keeps 0.92–0.93 but has a worst query at 0.18. The latency it buys is small
on a uniform corpus and large on real hub-heavy text (one `graph_completion`
search went from 332 ms to 76 ms). Treat it as a knob for a corpus with known
hubs, measured on that corpus, not as a default.

The cap bounds single-query graph search at depth 1 only: it has no effect with
a `neighborhood_depth` above 1. Batch graph search
(`brute_force_triplet_search_batch`, several queries at once) loads the whole
graph, and the cap does not apply to it — see
[Operations: search](https://docs.cognee.ai/rust/core-concepts/main-operations/legacy-operations/search.md).

`PgGraphAdapter` applies the cap in SQL; every other backend gets the same
semantics from `GraphDBTrait::get_neighborhood_scoped`'s client-side default.

## Hybrid retriever knobs

The `HYBRID_COMPLETION` search type (`SearchType::HybridCompletion`) accepts a
set of per-request tuning knobs. These are **library / orchestrator-only** —
typed `Option<...>` fields on
[`SearchParams`](https://github.com/topoteretes/cognee-rs/blob/main/crates/search/src/types/search_params.rs),
populated from the **snake\_case JSON keys** inside
`SearchRequest.retriever_specific_config`. They have no env binding.

> [!WARNING]
>
> **Not reachable from the CLI.** `cognee-cli search` hardcodes
> `retriever_specific_config: None`, so these knobs are reachable only from a Rust
> caller that builds a `SearchRequest` with a populated `retriever_specific_config`,
> or from a language binding, which forwards its `retrieverSpecificConfig` search
> option verbatim (camelCase option name, snake\_case knob keys inside).

When a knob is unset the retriever falls back through
`retriever_specific_config.<knob>` → `SearchRequest.top_k` capped at 10 → the
`HybridRetriever::new` constructor default (an explicit per-lane knob is never
capped):

| `SearchParams` field / JSON key | Effective Rust default |
| - | - |
| `chunks_top_k` | `min(top_k, 10)`, else `5` |
| `entities_top_k` | `min(top_k, 10)`, else `5` |
| `facts_top_k` | `min(top_k, 10)`, else `5` |
| `max_edges_per_entity` | `10` |
| `text_summaries_top_k` | `None` (no fallback) |
| `chunk_lane_fusion` | `"relative_score"` |
| `summary_lane_weight` | `0.75` |
| `use_importance_weight` | `true` |
| `include_external_metadata` | `false` |
| `external_metadata_keys` | `[]` |
| `include_global_context_index` | `false` |
| `global_context_index_top_k` | `3` |
| `node_name` | `None` |
| `node_name_filter_operator` | `"OR"` (or `"AND"`; anything else is an error) |
| `candidate_top_k` | `top_k * 4` (TEMPORAL only) |

**TEMPORAL.** `TEMPORAL` search (`SearchType::Temporal`) runs the same hybrid
fetch, so it reads the same keys, with two differences. The fallback above
applies to the `HYBRID_COMPLETION` lanes only: TEMPORAL's `top_k` is
`SearchRequest.top_k` (`5` when unset) and is **not** capped at 10. And its chunk
and entity lanes are sized by `candidate_top_k` and its fact lane by `top_k`,
overriding `chunks_top_k` / `entities_top_k` / `facts_top_k` (`text_summaries_top_k`
is ignored too: the summary lane follows the chunk lane); the time-window
rerank then cuts the candidates back to `top_k`. A `top_k` of `0` or a
`candidate_top_k` below `top_k` is rejected with `InvalidInput`.

**Chunk-lane fusion.** `chunk_lane_fusion` chooses how the `DocumentChunk_text`
lane and the `TextSummary_text` lane are combined:

* `"relative_score"` (default) normalises each lane's similarities to `[0, 1]`
  against that lane's own candidates and adds them, the summary lane weighted by
  `summary_lane_weight` (the chunk lane always weighs `1.0`).
* `"reciprocal_rank"` is RRF over ranks only.

The default avoids RRF deliberately: RRF's constant is calibrated for candidate
lists of thousands, and on these short lists "present in both lanes" outranks
"similar to the query". Measured over 15 probe questions on *Alice in
Wonderland*, relative-score fusion raised MRR in all four tested configurations
(0.35–0.54 → 0.47–0.56). Set `chunk_lane_fusion = "reciprocal_rank"` to get
rank-only RRF back.

**Truth weighting.** `use_truth_weight` (default `false`) re-ranks the chunk
lane by truth-subspace alignment with the query. It needs exactly one dataset in
scope and chunk coordinates at the live centroid epoch, which
`improve(build_truth_subspace=true)` builds from the session's distilled
learnings; without both, ranking stays at baseline. A failed build keeps the
previous epoch live and reports the `build_truth_subspace` stage as `errored`; a
graph backend without truth-state support (`GraphDBTrait::supports_truth_state`)
reports it as `skipped` / `backend_unsupported`. The stage's record is in
`ImproveResult.stages` (`stages` in the bindings' improve result).

**External metadata.** Metadata is opt-in and allowlist-only. With
`include_external_metadata` off (the default), the raw stored value is removed
from returned passage objects and from the completion context. With it on, only
the non-null keys named in `external_metadata_keys` are returned, and rendered
as `key: value` lines above the passage. A missing, malformed, or non-object
value yields `external_metadata: null` and does not fail the search. This is the
query-time side only: cognify does not yet copy document metadata into the
vector payloads, and existing datasets will need re-cognifying once it does
(there is no backfill).

**DLT rows.** Cognify indexes a DLT row (a document whose `external_metadata`
has `source: "dlt"`) into `DltRow_text`, never `DocumentChunk_text`. This fills
the hybrid lanes that were already in place: when
`DltRow_text` exists, the chunk lane searches it next to `DocumentChunk_text`
and ranks both as one list, and the entity lane adds `DltColumn_properties`,
`SchemaTable_name` and `SchemaRelationship_name`. A store without DLT data
behaves as before. Graph completion now also searches `DltRow_text`. Datasets
cognified before this layout need re-cognifying after deleting their old graph
and vector rows; there is no migration.

**Global context index.** `include_global_context_index` (default `false`)
makes `HYBRID_COMPLETION` prepend the same dataset-scoped root and nearest
bucket summaries as `GRAPH_COMPLETION`; `global_context_index_top_k` (default
`3`) limits the bucket summaries, and a value above `10000` fails the search
with `InvalidInput`. The index must first be built by `improve()`, which runs
the `global_context_index` stage by default (`IMPROVE_GLOBAL_CONTEXT_INDEX`; see
[Operations: improve](https://docs.cognee.ai/rust/core-concepts/main-operations/improve.md)). Missing or legacy index data
degrades to the ordinary hybrid context instead of failing the search. The
HTTP-facing degradation notes live with the server's search-router docs, which
are not part of the `cognee-rs` repository.

## Search history

| Env var | `Settings` field | Default |
| - | - | - |
| `COGNEE_LOG_SEARCH_HISTORY` | `log_search_history` | `true` |

When on, each search (CLI `search` / `recall`, bindings) records one query row
and one result row after retrieval. They carry the searched dataset's
`dataset_id` when exactly one dataset was searched. Turn it off with
`cognee-cli config set log_search_history false` or
`COGNEE_LOG_SEARCH_HISTORY=false`. This setting is the only switch: the
per-request `SearchRequest::save_interaction` (`saveInteraction` /
`save_interaction` in the bindings) is removed, and CLI `search`, which used
to skip history, now records it too.

## Recall warm-up short-circuit

Before searching the graph, recall checks `pipeline_runs` for the datasets the
caller can read. When no pipeline has run on them, a graph-only recall
returns one `system` item with `status: "memory_warming_up"` instead of
searching; when no build there ever completed and the latest one failed, it
returns `status: "build_failed"` with the error. Data that was added but not
yet cognified is searched as usual. The check reads no graph or vector store, and treats the graph as
built when it cannot tell. Next to other sources a cold graph contributes
nothing, and an `only_context` recall always searches.

The CLI `recall` and the bindings enable the check. A hand-built orchestrator
probes only when given a `GraphWarmup` (`SearchBuilder::with_graph_warmup`);
without one, recall searches as before. This is a breaking change for Rust
callers: `RecallSource` gained a `System` variant, so an exhaustive `match` on
it needs a new arm.

| Env var | Key | Default | Effect |
| - | - | - | - |
| `RECALL_WARMUP_SHORTCIRCUIT` | `recall.warmup_shortcircuit` | `true` | `false` turns the check off; recall always searches. |
| `RECALL_WARMUP_THRESHOLD` | `recall.warmup_threshold` | `1` | The datapoint count a graph needs to count as built, reported back as the note's `threshold`. It changes no verdict: a built graph always reports a count above any threshold, and `0` does not make an unbuilt one count. |
| `RECALL_WARMUP_CACHE_TTL` | `recall.warmup_cache_ttl` | `60` | Seconds a "built" verdict is cached; a negative value caches nothing. A non-numeric value is dropped silently from env (the previous value stays) and rejected by `config set`. A "not built" verdict is never cached, so the first recall after a build searches it. |

## Improve (self-improvement loop)

The `improve` engine section is configured with `IMPROVE_*`.
`Settings::improve_config` resolves and checks it: a negative count, a negative or
NaN `debounce_seconds`, a `feedback_alpha` outside (0, 1], an unknown stage name or the fatal
`persist_session_qa` in `stages_disabled` is an error. An explicit `improve()`
(the CLI verb, the bindings) fails on it; the automatic
improve after a session `remember()` is skipped with a warning instead, so the
entry is still stored. A removed stage name (`triplet_enrichment`) is ignored
with a warning. The stages themselves are described in
[Operations: improve](https://docs.cognee.ai/rust/core-concepts/main-operations/improve.md).

| Env var | Key | Default | Effect |
| - | - | - | - |
| `IMPROVE_AUTO_ENABLED` | `improve.auto_enabled` | `true` | Run `improve()` after a session `remember()` (detached), and the self-improvement pass of a permanent `remember()`. `false` is the kill switch on both paths; an explicit `self_improvement` does not override it. |
| `IMPROVE_DEBOUNCE_ENTRIES` | `improve.debounce_entries` | `1` | Auto-improve fires only once this many new session entries accumulated since the last one; `0` turns the entry trigger off (with `debounce_seconds` also `0` there is no debounce, and every `remember()` fires). With `debounce_seconds` set, the default `1` steps aside (set `>= 2` to combine both). |
| `IMPROVE_DEBOUNCE_SECONDS` | `improve.debounce_seconds` | `0` | … or once this many seconds passed; `0` turns the time trigger off. Checked only on the next `remember()`: there is no timer. |
| `IMPROVE_STAGES_DISABLED` | `improve.stages_disabled` | *(empty)* | Comma-separated stage names skipped with `disabled_by_config`. |
| `IMPROVE_FEEDBACK_ALPHA` | `improve.feedback_alpha` | `0.1` | `feedback_weights` learning rate, in (0, 1], when a run passes none (for example the CLI without `--feedback-alpha`). |
| `IMPROVE_REVIEW_CONFLICTS` | `improve.review_conflicts` | `true` | Default of the per-call `review_conflicts` argument (an explicit value wins either way); off reports `turned_off`. The stage is not ported yet, so on reports `no_llm_configured`, `edge_evidence_disabled` (`EDGE_EVIDENCE_ENABLED` off) or `not_ported`. |
| `IMPROVE_GLOBAL_CONTEXT_INDEX` | `improve.global_context_index` | `true` | Default of the per-call `build_global_context_index` argument (an explicit value wins either way), including the automatic improve after `remember()`; off reports `turned_off`. |
| `IMPROVE_EFFECTIVE_DATE_KEY` | `improve.effective_date_key` | `effective_date` | Document metadata key of a source's date (read by `review_conflicts`; not ported yet). |
| `IMPROVE_TRACE_WINDOW_STEPS` | `improve.trace_window_steps` | `0` | Agent trace steps per persisted document; `0` = all pending. Not read yet. |
| `IMPROVE_TRACE_WINDOWS_PER_RUN` | `improve.trace_windows_per_run` | `0` | Trace documents one run may cognify; `0` = drain. Not read yet. |
| `IMPROVE_DISTILL_MAX_BATCHES_PER_RUN` | `improve.distill_max_batches_per_run` | `0` | Curator batches per distillation run; `0` = uncapped. Not read yet. |

`IMPROVE_AUTO_ENABLED`, `IMPROVE_REVIEW_CONFLICTS` and
`IMPROVE_GLOBAL_CONTEXT_INDEX` accept `true|1|yes|on`
and `false|0|no|off`; any other value is ignored with a warning. A numeric
`IMPROVE_*` env value that does not parse is dropped silently; one that parses
but is out of range is kept and makes the configuration invalid.

### Feedback & personalization

Cognee-wide `Settings` fields. Each number is
range-checked: out of range is an error from `ConfigManager::set` (and every
binding / `cognee-cli config set`), and is ignored with a warning from env.

| Env var | `Settings` field | Default | Effect |
| - | - | - | - |
| `DEFAULT_FEEDBACK_INFLUENCE` | `default_feedback_influence` | `0.0` | Blend weight of the learned feedback signal in graph search, in \[0, 1]: the `feedback_influence` of a search request that sets none. A positive value also makes `HYBRID_COMPLETION` fall back to `GRAPH_COMPLETION`. |
| `PREFERENCE_ALPHA` | `preference_alpha` | `0.3` | How far one rating pulls a personal `prefers` weight, in (0, 1]. Read by improve's `update_user_preferences`. |
| `PREFERENCE_BETA` | `preference_beta` | `0.02` | Per-turn decay of an untouched `prefers` weight, in \[0, 1); applied on read, by the preference update and by the retrievers. |
| `PERSONALIZATION_ENABLED` | `personalization_enabled` | `false` | Master switch of preference personalization: gates improve's `update_user_preferences` stage and the retrievers' preference read (graph, RAG, and hybrid completion). Off, nothing is written or read. |
| `PERSONALIZATION_INFLUENCE` | `personalization_influence` | `0.3` | The most a personal `prefers` weight may move a ranking score, in \[0, 1] (graph triplet ranking and RAG/hybrid chunk ranking). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.