# π SAP Docs Search Testing Guide
Test the enhanced context-aware search functionality using these testing tools.
## π Test Files Available
### 1. **Simple Search Test** (`test-search.ts`)
Quick command-line search testing with any keyword.
```bash
# Test with default keyword
npx tsx test-search.ts
# Test specific keywords
npx tsx test-search.ts wizard
npx tsx test-search.ts "cds entity"
npx tsx test-search.ts "wdi5 testing"
npx tsx test-search.ts annotation
```
**Features:**
- β±οΈ Performance timing
- π Result summary
- π― Context detection display
- π Top result preview
### 2. **Interactive Search Test** (`test-search-interactive.ts`)
Advanced testing with multiple modes and analysis.
```bash
# Interactive mode
npx tsx test-search-interactive.ts
# Run all predefined tests
npx tsx test-search-interactive.ts all
# Test specific query
npx tsx test-search-interactive.ts "your search term"
```
**Interactive Commands:**
- `all` - Run all predefined test cases
- `list` - Show predefined test cases
- `quit` / `exit` - Exit interactive mode
- Any keyword - Test search
**Features:**
- π§ͺ Predefined test cases with expected contexts
- β
Context validation
- π Library breakdown analysis
- π Top result highlighting
- β±οΈ Performance metrics
### 3. **HTTP API Tests** (`test-search.http`) β
**WORKING**
Test the HTTP server endpoints (requires VS Code REST Client or similar).
**First, start the HTTP server:**
```bash
npm run start:http
```
**Then use the `.http` file to test:**
- Server status check
- Various search queries
- Context-specific tests
- **Full search functionality** with context-aware results
**Example response for "wizard":**
```json
{
"role": "assistant",
"content": "Found 10 results for 'wizard' π¨ **UI5 Context**:\n\nπΉ **UI5 API Documentation:**\nβοΈ **sap.f.SidePanel** (Score: 100)..."
}
```
## π― Test Categories
### **UI5 Context Tests**
```bash
npx tsx test-search.ts wizard
npx tsx test-search.ts "sap.m.Button"
npx tsx test-search.ts "fiori elements"
```
Expected: π¨ **UI5 Context** with UI5 API/Samples first
### **CAP Context Tests**
```bash
npx tsx test-search.ts "cds entity"
npx tsx test-search.ts service
npx tsx test-search.ts aspect
```
Expected: ποΈ **CAP Context** with CAP Documentation first
### **wdi5 Context Tests**
```bash
npx tsx test-search.ts "wdi5 testing"
npx tsx test-search.ts "browser automation"
npx tsx test-search.ts "e2e test"
```
Expected: π§ͺ **wdi5 Context** with wdi5 Documentation first
### **Mixed Context Tests**
```bash
npx tsx test-search.ts annotation
npx tsx test-search.ts authentication
npx tsx test-search.ts routing
```
Expected: Context varies based on strongest signal
## π Understanding Results
### **Context Detection** π―
- **π¨ UI5 Context**: UI5 controls, Fiori, frontend development
- **ποΈ CAP Context**: CDS, entities, services, backend development
- **π§ͺ wdi5 Context**: Testing, automation, browser testing
- **π MIXED Context**: Cross-platform or unclear context
### **Scoring System** β
- **Score 100**: Perfect matches
- **Score 90+**: High relevance matches
- **Score 80+**: Good matches with context boost
- **Score 70+**: Moderate relevance
- **Score <70**: Lower relevance (often filtered out)
### **Library Prioritization** π
Results are ordered by relevance score, with context-aware penalties:
- **CAP queries**: OpenUI5 results get 70% penalty (unless integration-related)
- **wdi5 queries**: OpenUI5 results get 80% penalty (unless testing-related)
- **UI5 queries**: CAP/wdi5 results get 60% penalty (unless backend/testing-related)
## π§ͺ Example Test Session
```bash
# Start interactive testing
npx tsx test-search-interactive.ts
π Enter search term (or command): wizard
π― Detected context: UI5
β
Context match: YES β
π Top result: βοΈ **sap.f.SidePanel** (Score: 100)...
π Libraries found: UI5-API, UI5-Samples
π Enter search term (or command): cds entity
π― Detected context: CAP
β
Context match: YES β
π Top result: βοΈ **Core / Built-in Types** (Score: 100)...
π Libraries found: CAP
π Enter search term (or command): all
π§ͺ Running all predefined test cases...
[Runs comprehensive test suite]
```
## π Quick Start
1. **Test a simple search:**
```bash
npx tsx test-search.ts wizard
```
2. **Run the full test suite:**
```bash
npx tsx test-search-interactive.ts all
```
3. **Test HTTP API (optional):**
```bash
npm run start:http
# Then use test-search.http file
```
## π Performance Benchmarks
Typical search times:
- **Simple queries**: 1-3 seconds
- **Complex queries**: 2-5 seconds
- **First search** (cold start): May take longer due to index loading
## π§ Troubleshooting
**No results found:**
- Check spelling
- Try broader terms
- Use predefined test cases to verify system works
**Slow performance:**
- First search loads index (normal)
- Subsequent searches should be faster
- Check available memory
**Wrong context detection:**
- Context is based on keyword analysis
- Mixed contexts are normal for generic terms
- Use more specific terms for better context detection