#!/bin/bash
# Test all 4 search modes with 10 natural language queries

API_URL="http://localhost:3003"
API_KEY="muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69"
LIMIT=10

QUERIES=(
	"someone talking about money"
	"car chase scene"
	"romantic conversation"
	"police investigation"
	"happy ending moment"
	"running away"
	"secret message"
	"crying emotional"
	"dinner scene"
	"airport goodbye"
)

MODES=("vector" "bm25" "hybrid" "smart")

echo "=== Search Mode Comparison Test ==="
echo ""

for q in "${!QUERIES[@]}"; do
	QUERY="${QUERIES[$q]}"
	echo "========================================"
	echo "Query $((q + 1)): \"$QUERY\""
	echo "========================================"

	for MODE in "${MODES[@]}"; do
		echo ""
		echo "--- Mode: $MODE ---"
		case $MODE in
		vector)
			RESULT=$(curl -s -X POST "$API_URL/api/v1/n8n/search" \
				-H "Content-Type: application/json" \
				-H "x-api-key: $API_KEY" \
				-d "{\"query\": \"$QUERY\", \"limit\": $LIMIT}")
			;;
		bm25)
			RESULT=$(curl -s -X POST "$API_URL/api/v1/n8n/search/bm25" \
				-H "Content-Type: application/json" \
				-H "x-api-key: $API_KEY" \
				-d "{\"query\": \"$QUERY\", \"limit\": $LIMIT}")
			;;
		hybrid)
			RESULT=$(curl -s -X POST "$API_URL/api/v1/n8n/search/hybrid" \
				-H "Content-Type: application/json" \
				-H "x-api-key: $API_KEY" \
				-d "{\"query\": \"$QUERY\", \"limit\": $LIMIT}")
			;;
		smart)
			RESULT=$(curl -s -X POST "$API_URL/api/v1/n8n/search/smart" \
				-H "Content-Type: application/json" \
				-H "x-api-key: $API_KEY" \
				-d "{\"query\": \"$QUERY\", \"limit\": $LIMIT}")
			;;
		esac

		echo "$RESULT" | jq -r '.hits[:5] | .[] | "  \(.id): \(.text) [score: \(.score)]"'
	done
	echo ""
done
