Configuration Guide
Configuration Guide
This guide explains how to update and manage configuration data in the Haya Routing Service. All configuration can be managed through JSON files and is automatically loaded into Qdrant for runtime use.
Overview
The Haya Routing Service uses several types of configuration:
- Hierarchy Data (
data/hierarchy-data.json) - Service, category, and collection definitions - Embedding Weights (
config/optimized-embedding-weights-v3.json) - Field weight configurations - Confidence Config (
config/confidence-config.json) - Confidence calculation settings - Boost/Penalty Config (
config/boost-penalty-config.json) - Query intent and keyword boosts - Query Intent Config (
config/query-intent-config.json) - Intent detection settings - Level Config (
data/level-config.json) - Level-based field and behavior definitions
Hierarchy Data Configuration
Location
data/hierarchy-data.json
Structure
The hierarchy data file contains three main sections:
{
"metadata": {
"description": "...",
"version": "2.0.0",
"tenant": "tenant-001",
"app": "app-001"
},
"services": [...],
"categories": [...],
"collections": [...]
}
Key Configuration Sections
1. Routing Keywords (Service Level)
Located in services[].level_context.routing_keywords:
{
"routing_keywords": {
"boost_keywords": [
"search",
"find",
"documentation"
],
"penalty_keywords": [
"api",
"sql",
"database"
],
"boost_value": 0.2,
"penalty_value": -0.6
}
}
Purpose: Controls keyword-based routing at the service level.
- boost_keywords: Keywords that increase similarity when found in queries
- penalty_keywords: Keywords that decrease similarity when found in queries
- boost_value: Amount to add to similarity (0.0 to 1.0)
- penalty_value: Amount to subtract from similarity (negative value)
Best Practices:
- Use specific phrases for better matching (e.g., "list all", "show network")
- Set higher boost values (0.5-0.6) for services that need stronger routing
- Set stronger penalties (-0.4 to -0.6) to prevent false matches
- Add SQL/REST-specific terms to Document Search penalty keywords
2. Query Intent Boosts (Service Level)
Located in services[].level_context.query_intent_boosts:
{
"query_intent_boosts": {
"documentation": 0.25,
"data_query": -0.25,
"api_call": 0.35
}
}
Purpose: Applies boosts/penalties based on detected query intent.
Intent Types:
documentation: User wants documentation/search resultsdata_query: User wants to query data/databasesapi_call: User wants to call APIsmcp_config: User wants MCP/model configuration
Best Practices:
- Use values between 0.25-0.35 for stronger intent-based routing
- Negative values penalize mismatched intents
3. Embedding Configuration
Located in services[].embedding_config and collections[].embedding_config:
{
"embedding_config": {
"weight_strategy": "context_heavy" // or "balanced"
}
}
For collections:
{
"embedding_config": {
"embedding_weights": {
"description_weight": 0.4,
"document_types_weight": 0.3,
"content_characteristics_weight": 0.3
}
}
}
Purpose: Controls how embeddings are generated for semantic matching.
Weight Strategies:
context_heavy: Emphasizes context fields (use_cases, domain_context)balanced: Equal weight across all fields
Updating Hierarchy Data
-
Edit the JSON file:
vim data/hierarchy-data.json -
Validate JSON syntax:
python3 -m json.tool data/hierarchy-data.json > /dev/null -
Register the updated data:
./fresh-register.shOr use the API:
curl -X POST "http://localhost:3000/api/v1/admin/hierarchy/bulk-register" \ -H "Content-Type: application/json" \ -d @data/hierarchy-data.json
Common Updates
Adding a New Service
- Add service object to
servicesarray - Set
level: 0,root_type, andlevel_context.routing_keywords - Register using
./fresh-register.sh
Updating Keyword Boosts
- Edit
routing_keywordsin service'slevel_context - Adjust
boost_valueandpenalty_value - Add/remove keywords from
boost_keywordsandpenalty_keywords - Re-register hierarchy data
Tuning Routing Accuracy
- Increase boost values (0.3 → 0.5-0.6) for services that need stronger routing
- Increase penalty values (-0.2 → -0.4 to -0.6) to prevent false matches
- Add phrase keywords (e.g., "list all", "show network") for better matching
- Add SQL/REST terms to Document Search penalties to prevent cross-service matches
Embedding Weights Configuration
Location
config/optimized-embedding-weights-v3.json
Structure
{
"level_0": {
"name_weight": 0.03,
"description_weight": 0.10,
"use_cases_weight": 0.28,
"capabilities_weight": 0.18,
"domain_context_weight": 0.20,
...
},
"level_1": { ... },
"level_2": { ... }
}
Purpose
Controls the relative importance of each field when generating embeddings. Higher weights mean the field has more influence on semantic matching.
Updating Embedding Weights
-
Edit the JSON file:
vim config/optimized-embedding-weights-v3.json -
Bootstrap to Qdrant:
npm run bootstrap-configsThis loads all config files from
config/into Qdrant. -
Verify:
curl "http://localhost:3000/api/v1/admin/config/embedding-weights?tenant_id=tenant-001&app_id=app-001"
Best Practices
- Use Cases should have highest weight (0.25-0.30) - they describe what the service does
- Domain Context should have high weight (0.20-0.25) - provides domain-specific context
- Description should have moderate weight (0.10-0.15) - general description
- Name should have low weight (0.03-0.05) - least important for matching
Confidence Configuration
Location
config/confidence-config.json
Structure
{
"confidence_calculation": {
"high_confidence_threshold": 0.7,
"clear_gap_threshold": 0.15,
"clear_winner_bonus": 0.1
}
}
Purpose
Controls how confidence scores are calculated from similarity scores.
- high_confidence_threshold: Minimum similarity for high confidence (0.7 = 70%)
- clear_gap_threshold: Minimum gap between top match and second match to apply bonus (0.15 = 15%)
- clear_winner_bonus: Bonus added when there's a clear winner (0.1 = 10%)
Updating Confidence Config
-
Edit the JSON file:
vim config/confidence-config.json -
Bootstrap to Qdrant:
npm run bootstrap-configs -
Restart service (configs are cached):
docker-compose restart haya-routing
Tuning Confidence
- Lower threshold (0.6-0.65): More routes accepted, but may include lower-quality matches
- Higher threshold (0.75-0.8): Only high-quality routes accepted, may reject valid routes
- Larger gap threshold (0.2-0.25): More strict about "clear winner" bonus
- Smaller gap threshold (0.1-0.12): More lenient about "clear winner" bonus
Boost/Penalty Configuration
Location
config/boost-penalty-config.json
Structure
{
"service_type_boosts": {
"service_level": {
"documentation": {
"SEARCH": 0.25,
"SQL": -0.25
},
"data_query": {
"SQL": 0.25,
"SEARCH": -0.25
}
}
},
"similarity_boosts": {
"service_type_hint": 0.25,
"context_match": {
"threshold": 0.7,
"multiplier": 0.2
}
}
}
Purpose
Provides global boost/penalty settings that apply across all services. These are used as fallbacks when service-specific settings aren't available.
Updating Boost/Penalty Config
-
Edit the JSON file:
vim config/boost-penalty-config.json -
Bootstrap to Qdrant:
npm run bootstrap-configs -
Restart service:
docker-compose restart haya-routing
Query Intent Configuration
Location
config/query-intent-config.json
Structure
{
"intent_patterns": {
"documentation": {
"keywords": ["how", "what", "show", "find"],
"patterns": ["how to", "how do", "what is"]
},
"data_query": {
"keywords": ["list", "count", "show", "get"],
"patterns": ["list all", "show me", "get data"]
}
}
}
Purpose
Defines patterns and keywords for detecting query intent.
Updating Query Intent Config
- Edit the JSON file
- Bootstrap to Qdrant:
npm run bootstrap-configs - Restart service
Level Configuration
Location
data/level-config.json
Structure
{
"0": {
"fields": ["root_type", "level_context"],
"parentLevels": null,
"embedding_method": "service",
"matching_strategy": "service-level"
},
"1": {
"fields": ["level_context"],
"parentLevels": [0],
"embedding_method": "category",
"matching_strategy": "category-level"
},
"2": {
"fields": ["level_context", "routing_info"],
"parentLevels": [0, 1],
"embedding_method": "collection",
"matching_strategy": "collection-level"
}
}
Purpose
Defines which fields are available at each hierarchy level and how matching works.
Updating Level Config
-
Edit the JSON file:
vim data/level-config.json -
Bootstrap to Qdrant:
npm run bootstrap-level-config -
Restart service
Configuration Workflow
Initial Setup
-
Bootstrap all configs:
npm run bootstrap-configs npm run bootstrap-level-config -
Register hierarchy data:
./fresh-register.sh
Updating Configuration
- Edit JSON files in
config/ordata/ - Validate JSON syntax:
python3 -m json.tool <file> > /dev/null - Bootstrap configs (if config files changed):
npm run bootstrap-configs - Re-register hierarchy (if hierarchy-data.json changed):
./fresh-register.sh - Restart service (if configs changed):
docker-compose restart haya-routing
Verifying Configuration
Check configs in Qdrant:
# Check embedding weights
curl "http://localhost:3000/api/v1/admin/config/embedding-weights?tenant_id=tenant-001&app_id=app-001"
# Check confidence config
curl "http://localhost:3000/api/v1/admin/config/confidence?tenant_id=tenant-001&app_id=app-001"
# Check level config
curl "http://localhost:3000/api/v1/admin/config/level-config?tenant_id=tenant-001&app_id=app-001"
Best Practices
Hierarchy Data
- Use specific keywords: Prefer phrases like "list all" over single words
- Balance boosts/penalties: Higher boosts (0.5-0.6) for services that need stronger routing
- Strong penalties: Use -0.4 to -0.6 penalties to prevent false matches
- Add SQL/REST terms to Document Search penalties: Prevents cross-service matches
- Test after changes: Always run tests after updating hierarchy data
Embedding Weights
- Prioritize use cases: Give highest weight to use_cases (0.25-0.30)
- Emphasize domain context: High weight for domain_context (0.20-0.25)
- Keep name weight low: Name should have minimal weight (0.03-0.05)
Confidence
- Start with defaults: Use 0.7 threshold, 0.15 gap, 0.1 bonus
- Adjust based on results: Lower threshold if too many rejections, raise if too many false positives
- Monitor test results: Use test suite to validate confidence settings
Troubleshooting
Config Not Loading
- Check JSON syntax:
python3 -m json.tool <file> - Verify bootstrap ran: Check logs for "Config loaded from Qdrant"
- Restart service: Configs are cached on startup
Changes Not Taking Effect
- Hierarchy data: Must re-register after changes
- Config files: Must bootstrap and restart service
- Check cache: Service caches configs on startup
Validation Errors
- Check required fields are present
- Verify field types match expected types
- Check level constraints (e.g., level 0 must have root_type)
Related Documentation
- Hierarchy Data Guide - Detailed hierarchy structure
- Routing Mechanics Guide - How routing works
- Test Script Guide - Testing configuration changes