Files
railseek6/test_search_queries.py

48 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify search functionality with different queries
"""
import requests
import json
LIGHTRAG_URL = 'http://localhost:3015'
API_KEY = 'jleu1212'
def test_search_queries():
"""Test search with different approaches to find bee classification"""
print("🔍 Testing Search Queries")
print("=" * 40)
headers = {'Content-Type': 'application/json', 'X-API-Key': API_KEY}
# Try searching for the exact classification text
queries = [
'bee',
'a photo of a bee',
'classification',
'Image 1 Classification',
'confidence: 1.00',
'photo of a bee',
'bee clipart'
]
for query in queries:
print(f'\n🔍 Searching for: "{query}"')
payload = {'query': query, 'top_k': 5, 'mode': 'local'}
try:
response = requests.post(f'{LIGHTRAG_URL}/search', json=payload, headers=headers, timeout=10)
if response.status_code == 200:
results = response.json().get('results', [])
print(f' Found {len(results)} results')
for i, result in enumerate(results):
content = result.get('content', '')[:200]
score = result.get('score', 0)
print(f' Result {i+1} (score: {score:.4f}): {content}...')
else:
print(f' ❌ Search failed: {response.status_code}')
except Exception as e:
print(f' ❌ Error: {e}')
if __name__ == "__main__":
test_search_queries()