Skip to content

Query Modes Deep-Dive

Product: v0.23.0 · Contract: OpenAPI · Spec ops: Ingestion cancel & fairness

Understanding EdgeQuake’s Multi-Strategy Retrieval System

EdgeQuake provides 6 query modes (naive, local, global, hybrid, mix, bypass), each optimized for different question types. Production default: mix (RRF-weighted fusion). API handlers fall back to mix when mode is omitted.

Storage touchpoints: which modes hit pgvector vs AGE vs KV is documented in Data Layer — How information is queried.



Different questions require fundamentally different retrieval strategies. Consider these queries about a document about climate science:

Question Optimal Strategy
“What is the greenhouse effect?” Vector search - Find semantically similar chunks
“How does Sarah Chen’s work relate to atmospheric modeling?” Graph traversal - Follow entity relationships
“What are the main themes in this document?” Global mode - Relationship-vector search + degree fallback (not GraphRAG community reports)
“Explain Sarah Chen’s contributions to climate research” Both - Entity + broader context

A single retrieval strategy cannot optimally serve all these query types. EdgeQuake’s multi-mode system allows you to match the strategy to your question.

┌─────────────────┐
│ PRECISION │
│ │
│ (Specific, │
│ Accurate) │
└────────┬────────┘
│
Naive ─────────┼─────────
│
┌────────────────────┼────────────────────┐
│ │ │
│ Hybrid │ │
│ │ │
┌────┴────┐ ┌────┴────┐ ┌────┴────┐
│ SPEED │ │ │ │ COVERAGE│
│ │──────────│ Mix │──────────│ │
│ (Fast, │ Local │ │ Global │ (Broad, │
│ Cheap) │ │ │ │Complete)│
└─────────┘ └─────────┘ └─────────┘

No mode is universally “best” - each makes different trade-offs.


Mode Vector Search Graph Traversal Best For
Naive ✅ ❌ Factual queries, keyword lookup
Local ✅ ✅ Entity-specific questions
Global ❌ ✅ Theme/topic analysis
Hybrid ✅ ✅ Local + Global + Naive (round-robin)
Mix ✅ ✅ RRF / weighted fusion (default)
Bypass ❌ ❌ Direct LLM, testing
┌─────────────────────────────────────────────────────────────────┐
│ QUERY MODE QUICK GUIDE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ "What is X?" → Naive (fast, direct) │
│ "How does A relate to B?" → Local (entity graph) │
│ "What are the main themes?" → Global (topic clusters) │
│ "Tell me about X and its impact"→ Hybrid (comprehensive) │
│ "I need custom weights" → Mix (tunable) │
│ "Skip RAG, just ask LLM" → Bypass (testing) │
│ │
└─────────────────────────────────────────────────────────────────┘

Use this decision tree to select the optimal mode:

┌─────────────────────────┐
│ Is RAG needed at all? │
└───────────┬─────────────┘
│
┌───────────────┴───────────────┐
│ │
YES NO
│ │
▼ ▼
┌───────────────────────┐ ┌───────────────┐
│ Does query mention │ │ BYPASS │
│ specific entities? │ │ (no RAG) │
└───────────┬───────────┘ └───────────────┘
│
┌───────────┴───────────┐
│ │
YES NO
│ │
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ Also asking about │ │ Asking about themes │
│ broader context? │ │ or overarching topics?│
└───────────┬───────────┘ └───────────┬───────────┘
│ │
┌───────┴───────┐ ┌───────┴───────┐
│ │ │ │
YES NO YES NO
│ │ │ │
▼ ▼ ▼ ▼
┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐
│HYBRID │ │ LOCAL │ │GLOBAL │ │ NAIVE │
│ │ │ │ │ │ │ │
└───────┘ └───────┘ └───────┘ └───────┘

FEAT0101: Vector similarity search only

Naive mode performs pure vector similarity search on document chunks, without graph traversal. It’s the fastest mode and works well for simple factual queries.

┌─────────────────────────────────────────────────────────────────┐
│ NAIVE MODE FLOW │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Query: "What is machine learning?" │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Embed Query │ → [0.23, -0.45, 0.87, ...] │
│ └────────┬────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────┐ │
│ │ Vector Database (pgvector) │ │
│ │ ┌────────┐ ┌────────┐ ┌────────┐ │ │
│ │ │chunk_1 │ │chunk_2 │ │chunk_3 │ ... │ │
│ │ │sim:0.92│ │sim:0.85│ │sim:0.78│ │ │
│ │ └────────┘ └────────┘ └────────┘ │ │
│ └─────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Top-K Chunks │ → ["ML is a subset of AI...", │
│ │ (scored) │ "Training neural networks..."] │
│ └────────┬────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ LLM Generation │ → "Machine learning is..." │
│ └─────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘

✅ Good for:

  • Simple factual questions (“What is X?”)
  • Keyword-based lookup
  • Fast response requirements
  • When graph data is sparse

❌ Avoid when:

  • Asking about relationships
  • Need comprehensive coverage
  • Entities are important
Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "What is the greenhouse effect?",
"mode": "naive"
}'
Metric Typical Value
Latency 100-300ms
Context tokens 500-2000
LLM calls 1

FEAT0102: Entity-centric graph traversal

Local mode combines vector search with graph traversal from identified entities. It excels at questions about specific entities and their relationships.

┌─────────────────────────────────────────────────────────────────┐
│ LOCAL MODE FLOW │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Query: "How does Sarah Chen work with the IPCC?" │
│ │ │
│ ▼ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Embed Query │ │ Extract Entities│ │
│ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────┐ ┌─────────────────────┐ │
│ │ Vector Search │ │ Entity Lookup │ │
│ │ (chunks) │ │ SARAH_CHEN, IPCC │ │
│ └────────┬────────┘ └────────┬────────────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌─────────────────────────┐ │
│ │ │ Graph Traversal │ │
│ │ │ │ │
│ │ │ SARAH_CHEN ──WORKS_WITH──▶ IPCC │
│ │ │ │ │ │
│ │ │ └──AUTHORED──▶ PAPER_1 │
│ │ │ │ │
│ │ └─────────────────────────┘ │
│ │ │ │
│ └──────────┬──────────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Merge Context │ │
│ │ (chunks + │ │
│ │ entities + │ │
│ │ relationships) │ │
│ └────────┬────────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ LLM Generation │ │
│ └─────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘

✅ Good for:

  • Questions about specific people, places, organizations
  • Relationship queries (“How does X relate to Y?”)
  • When entity context enriches the answer
  • Named entity questions

❌ Avoid when:

  • Entities not well-extracted
  • Asking about abstract concepts
  • Need speed over comprehensiveness
Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "What is Sarah Chen'\''s research focus?",
"mode": "local"
}'
Metric Typical Value
Latency 200-500ms
Context tokens 1000-3000
Graph queries 3-10

FEAT0103: Relationship-centric global search (SPEC-023 I2)

Global mode uses high-level query embeddings against relationship vectors in the vector store, then batch-fetches connected entities and their source chunks. When no relationship vectors match, it falls back to high-degree nodes in the graph.

Important: This is not Microsoft GraphRAG community-report search. EdgeQuake does not generate hierarchical community summaries at query time today.

┌─────────────────────────────────────────────────────────────────┐
│ GLOBAL MODE FLOW (actual) │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Query: "What themes connect these research entities?" │
│ │ │
│ ▼ │
│ High-level keyword embedding │
│ │ │
│ ▼ │
│ Vector ANN on type=relationship rows │
│ │ │
│ ├── hits ──► src/tgt entities + relationship text │
│ │ │
│ └── empty ──► popular nodes by degree (graph fallback) │
│ │ │
│ ▼ │
│ Batch node + degree fetch (no N+1) │
│ │ │
│ ▼ │
│ Collect linked chunk IDs → chunk vector re-rank │
│ │
└─────────────────────────────────────────────────────────────────┘

✅ Good for:

  • “What are the main themes/topics?”
  • Summary questions
  • Overview requests
  • When breadth matters more than depth

❌ Avoid when:

  • Asking about specific entities
  • Need precise factual answers
  • Speed is critical
Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "What topics does this document cover?",
"mode": "global"
}'
Metric Typical Value
Latency 300-800ms
Context tokens 2000-4000
Communities 5-20

FEAT0104: Combines Local, Global, and Naive (round-robin interleave)

Hybrid mode interleaves the Local, Global, and Naive arms round-robin, pulling chunk candidates from each. It is not the default — mix is (see Mix Mode); use hybrid when you want a deterministic three-arm interleave without weight tuning.

┌─────────────────────────────────────────────────────────────────┐
│ HYBRID MODE FLOW │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Query: "Explain Sarah Chen's impact on climate modeling" │
│ │ │
│ ├─────────────────────────────────────┐ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ LOCAL PATH │ │ GLOBAL PATH │ │
│ │ │ │ │ │
│ │ • Vector search│ │ • Relationship │ │
│ │ • Entity lookup│ │ vectors │ │
│ │ • Neighborhood │ │ • Degree │ │
│ │ traversal │ │ fallback │ │
│ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │
│ │ ┌───────────────────────────┐ │ │
│ └─▶│ CONTEXT FUSION │◀───┘ │
│ │ │ │
│ │ 1. Deduplicate entities │ │
│ │ 2. Merge relationships │ │
│ │ 3. Combine chunks │ │
│ │ 4. Apply token budget │ │
│ └─────────────┬─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────┐ │
│ │ LLM Generation │ │
│ │ (comprehensive answer)│ │
│ └─────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘

✅ Good for:

  • Complex, multi-faceted questions
  • Deterministic Local + Global + Naive interleave
  • Comprehensive answers needed

Not the default. The production default is mix (weighted/RRF fusion); hybrid is the round-robin alternative.

❌ Avoid when:

  • Speed is critical
  • Token budget is tight
  • Simple factual queries
Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "Explain the relationship between ML and climate research",
"mode": "hybrid"
}'
Metric Typical Value
Latency 400-1000ms
Context tokens 3000-4000
LLM calls 1

FEAT0105: Weighted blend of all three arms (production default)

Mix mode runs the Local, Global, and Naive arms in parallel and blends their results by weighted score (min-max normalized per arm, then weighted sum — QueryEngineConfig::{mix_local_weight, mix_global_weight, mix_naive_weight}, which need not sum to 1). This is the production default: API handlers fall back to QueryMode::Mix when mode is omitted.

Mix arm weights are set per request via mix_weights on the query body (overrides engine/env defaults):

{
"query": "Your question here",
"mode": "mix",
"mix_weights": { "local": 1.0, "global": 1.0, "naive": 1.0 }
}

Fleet defaults are engine config / env: EDGEQUAKE_MIX_LOCAL_WEIGHT, EDGEQUAKE_MIX_GLOBAL_WEIGHT, EDGEQUAKE_MIX_NAIVE_WEIGHT (need not sum to 1). Fusion is round-robin by default; EDGEQUAKE_MIX_FUSION=rrf is an ablation option.

✅ Good for:

  • Production defaults — best coverage with weighted fusion
  • Per-request arm tuning via mix_weights
  • A/B testing retrieval strategies
  • Domain-specific tuning via env weights

FEAT0106: Direct LLM, no retrieval

Bypass mode skips RAG entirely and sends the query directly to the LLM. Useful for testing or when external knowledge isn’t needed.

Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "What is 2 + 2?",
"mode": "bypass"
}'

Mode Latency Accuracy Context Cost
Naive ⚡ Fast (100-300ms) ⭐⭐⭐ Good Small 💵 Low
Local 🚀 Medium (200-500ms) ⭐⭐⭐⭐ High Medium 💵💵 Medium
Global 🐢 Slow (300-800ms) ⭐⭐⭐⭐ High Large 💵💵 Medium
Hybrid 🐢 Slow (400-1000ms) ⭐⭐⭐⭐⭐ Best Large 💵💵💵 High
Mix Variable Tunable Tunable Variable
Bypass ⚡ Fastest ⭐ LLM only None 💵 Low
┌─────────────────────────────────────────────────────────────────┐
│ RESOURCE USAGE BY MODE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Naive ████░░░░░░░░░░░░░░░░ (Vector only) │
│ │
│ Local ████████░░░░░░░░░░░░ (Vector + Graph node) │
│ │
│ Global ██████████░░░░░░░░░░ (Relationship vectors) │
│ │
│ Hybrid ████████████████░░░░ (All sources) │
│ │
│ Mix ████████████░░░░░░░░ (Weighted blend) │
│ │
│ ─────────────────────────────────────────► │
│ Low High │
│ │
└─────────────────────────────────────────────────────────────────┘

QueryEngineConfig {
default_mode: QueryMode::Mix, // production default (from code)
max_entities: 60, // LightRAG top_k=60 parity
max_relationships: 60,
max_chunks: 20, // LightRAG chunk_top_k=20 parity
max_context_tokens: 30000,
graph_depth: 2,
min_score: 0.1, // EDGEQUAKE_MIN_ENTITY_SCORE override
use_keyword_extraction: true,
}

Restrict retrieval to a document subset via document_filter on the query request:

{
"query": "What are the findings?",
"mode": "hybrid",
"document_filter": {
"document_ids": ["doc-uuid-1", "doc-uuid-2"],
"date_from": "2024-01-01",
"date_to": "2024-12-31",
"pattern": "*.pdf"
}
}
Field Behavior
document_ids Explicit allow-list (fast path when alone)
date_from / date_to KV scan + AND with ids
pattern Glob on document paths; union with explicit ids

Vector pre-filter uses materialized document_id columns (Tier 2/3) — see Vector Storage.

Flag Effect
context_only: true Return retrieved context only (no LLM answer); result cache enabled (P-G9)
prompt_only: true Return formatted prompt without calling LLM
Parameter Default Effect
max_chunks 20 More chunks = more context, higher cost
max_entities 60 More entities = richer graph context
max_context_tokens 30000 Token budget for LLM context
graph_depth 2 How many hops in graph traversal
min_score 0.1 Similarity threshold for inclusion (EDGEQUAKE_MIN_ENTITY_SCORE)

For Naive mode:

  • Increase max_chunks for better coverage
  • Lower min_score for more permissive matching

For Local mode:

  • Increase graph_depth for deeper relationships
  • Balance max_entities vs max_chunks

For Global mode:

  • Ensure communities are well-formed
  • Consider community detection parameters

For Hybrid mode:

  • Use max_context_tokens to balance cost
  • Enable reranking for better precision

Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-H "X-Workspace-ID: your-workspace" \
-d '{
"query": "What is the main finding?",
"mode": "naive"
}'
Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "Explain the climate research methodology",
"mode": "hybrid",
"enable_rerank": true,
"rerank_top_k": 5
}'
Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "Your question",
"mode": "local",
"context_only": true
}'

This returns only the retrieved context without LLM generation, useful for debugging retrieval quality.

Terminal window
curl -X POST http://localhost:8080/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"query": "Your question",
"mode": "hybrid",
"prompt_only": true
}'

Returns the formatted prompt that would be sent to the LLM.