Build an Interactive RAG Search Debugger with Vue and Qdrant

If you have ever built a Retrieval-Augmented Generation (RAG) pipeline, you already know the sinking feeling of watching your LLM hallucinate an answer despite passing it context. You check your vector database, run a manual similarity search, and stare at a wall of JSON containing floating-point arrays and distance scores.

Vector 0.7841? Is that good? Why did this specific document chunk get pulled instead of the one with the policy update?

Standard logging frameworks are practically useless for debugging vector search. Traditional logs capture SQL queries and HTTP status codes, but they struggle to visualize high-dimensional vector spaces, semantic similarity thresholds, payload filtering bugs, and hybrid sparse-dense score distributions.

If you want to fix your RAG application, you need to see what your vector database sees. You need a dedicated RAG search debugger.

In this deep-dive guide, we are going to build a production-ready, interactive RAG Search Debugger using Vue 3 (Composition API) on the frontend and Qdrant as our vector search engine backend. By the end of this article, you will have a fully functioning debugging workbench capable of real-time query tweaking, payload filter inspection, distance metric swapping, and visual relevance analysis.


📋 Table of Contents


The Anatomy of a RAG Search Failure

Before writing any code, let's look at why RAG pipelines break down in production. Most developers assume that if an LLM gives a bad answer, the prompt engineering is flawed or the embedding model is weak. Often, the root cause is hidden deeper inside the retrieval layer:

  1. The Curse of Dimensionality and Distance Metrics: Swapping from Cosine distance to Dot Product or Euclidean ($L2$) without normalizing your vectors will completely invert your search results.
  2. Payload Filtering Mismatches: Your semantic search finds a brilliant document, but your metadata filter (e.g., tenant_id == "org_99" or is_archived == false) silently eliminates it post-search because the index wasn't optimized.
  3. Chunking Boundary Issues: The relevant sentence sits right on the boundary of chunk 4 and chunk 5, causing semantic fragmentation where neither chunk captures enough context.
  4. Hybrid Search Weight Imbalance: When combining sparse keyword matching (BM25) with dense vector search, an improper alpha or scaling coefficient can drown out exact lexical matches with vague semantic neighbors.

A standard terminal output won't help you diagnose these edge cases. We need an interactive graphical workbench.


Architecture Overview: Vue 3 Meets Qdrant REST and gRPC APIs

Our debugging tool follows a clean client-server-database architecture. Because Qdrant exposes a robust REST API alongside its high-performance gRPC interface, our Vue frontend can communicate directly with Qdrant for local development, or through a lightweight backend proxying layer in production.

+------------------------------------------------------------+
|                       Vue 3 Frontend                       |
|  +--------------------+  +------------------------------+  |
|  | Search Workbench   |  | Parameter Inspector (Pinia)  |  |
|  +--------------------+  +------------------------------+  |
+------------------------------------------------------------+
                              |
                     HTTP / REST / JSON
                              v
+------------------------------------------------------------+
|                       Qdrant Engine                        |
|  +------------------------------------------------------+  |
|  | Collections | Dense Index | Sparse Index | Payloads  |  |
|  +------------------------------------------------------+  |
+------------------------------------------------------------+

Let's build this step by step.


1. Setting Up the Qdrant Client and Local Dev Environment

To run our debugging UI, we need a running instance of Qdrant populated with sample documents. We will spin up Qdrant using Docker Compose and seed it with a test collection of technical documentation chunks.

Create a docker-compose.yml file in your workspace root:

services:
  qdrant:
    image: qdrant/qdrant:v1.12.x
    ports:
      - "6333:6333"
      - "6334:6334"
    volumes:
      - qdrant_storage:/qdrant/storage
    environment:
      - QDRANT__SERVICE__HTTP_PORT=6333

volumes:
  qdrant_storage:

Spin it up with:

docker compose up -d

Next, let's write a quick seeding script in Node.js using the official @qdrant/js-client-rest package to populate a collection named rag_debug_docs with mock vectors and rich metadata payloads.

npm init -y
npm install @qdrant/js-client-rest dotenv

Create seed.js:

import { QdrantClient } from '@qdrant/js-client-rest';

const client = new QdrantClient({ host: 'localhost', port: 6333 });

async function seed() {
  const collectionName = 'rag_debug_docs';
  
  // Check if collection exists
  const collections = await client.getCollections();
  const exists = collections.collections.some(c => c.name === collectionName);

  if (exists) {
    await client.deleteCollection(collectionName);
  }

  // Create collection with 4-dimensional vectors for easy manual debugging
  await client.createCollection(collectionName, {
    vectors: {
      size: 4,
      distance: 'Cosine',
    },
  });

  // Insert mock data representing internal dev docs
  await client.upsert(collectionName, {
    wait: true,
    points: [
      {
        id: 1,
        vector: [0.12, 0.89, 0.45, 0.02],
        payload: {
          title: 'Database Migration Runbook',
          category: 'infrastructure',
          access_level: 'internal',
          version: 2.1,
          content: 'Always take a point-in-time snapshot before running alter table statements on production tables exceeding 100GB.'
        }
      },
      {
        id: 2,
        vector: [0.85, 0.11, 0.03, 0.67],
        payload: {
          title: 'OAuth2 Token Expiration Policy',
          category: 'security',
          access_level: 'public',
          version: 1.0,
          content: 'Access tokens expire strictly after 15 minutes. Refresh tokens are valid for 7 days and support single rotation.'
        }
      },
      {
        id: 3,
        vector: [0.15, 0.82, 0.48, 0.05],
        payload: {
          title: 'Zero-Downtime Deployment Guide',
          category: 'infrastructure',
          access_level: 'internal',
          version: 3.4,
          content: 'Use rolling updates with readiness probes configured to wait at least 30 seconds before draining active connections.'
        }
      }
    ]
  });

  console.log('Successfully seeded Qdrant collection!');
}

seed().catch(console.error);

2. Designing the Vue 3 Reactive State Store for Search Parameters

Our Vue debugger needs to manage a complex state tree: active query text, manual vector overrides, distance metrics, payload filter conditions, score thresholds, and limit parameters.

We will use Vue 3's Composition API with a dedicated reactive composable (useRagDebugger) to keep our logic modular and clean.

Create src/composables/useRagDebugger.js:

import { reactive, ref, computed } from 'vue';
import { QdrantClient } from '@qdrant/js-client-rest';

const client = new QdrantClient({ host: 'localhost', port: 6333, checkCompatibility: false });

export function useRagDebugger() {
  const collectionName = ref('rag_debug_docs');
  
  // Search parameters state
  const searchParams = reactive({
    queryText: '',
    vectorInput: [0.1, 0.8, 0.4, 0.0],
    useManualVector: false,
    limit: 5,
    scoreThreshold: 0.0,
    distanceMetric: 'Cosine',
    selectedCategory: 'all',
    accessLevel: 'internal'
  });

  const searchResults = ref([]);
  const executionTimeMs = ref(0);
  const isLoading = ref(false);
  const errorMessage = ref(null);

  // Build Qdrant filter object dynamically based on UI state
  const buildFilter = () => {
    const mustConditions = [];

    if (searchParams.selectedCategory !== 'all') {
      mustConditions.push({
        key: 'category',
        match: { value: searchParams.selectedCategory }
      });
    }

    if (searchParams.accessLevel) {
      mustConditions.push({
        key: 'access_level',
        match: { value: searchParams.accessLevel }
      });
    }

    return mustConditions.length > 0 ? { must: mustConditions } : undefined;
  };

  const executeSearch = async () => {
    isLoading.value = true;
    errorMessage.value = null;
    const startTime = performance.now();

    try {
      const vectorToSearch = searchParams.useManualVector
        ? searchParams.vectorInput
        : await mockEmbedQuery(searchParams.queryText);

      const response = await client.search(collectionName.value, {
        vector: vectorToSearch,
        limit: searchParams.limit,
        score_threshold: searchParams.scoreThreshold > 0 ? searchParams.scoreThreshold : undefined,
        filter: buildFilter(),
        with_payload: true,
        with_vector: true
      });

      searchResults.value = response;
      executionTimeMs.value = (performance.now() - startTime).toFixed(2);
    } catch (err) {
      errorMessage.value = err.message;
      console.error('Qdrant search error:', err);
    } finally {
      isLoading.value = false;
    }
  };

  // Helper mock embedding function for debugging workbench
  const mockEmbedQuery = async (text) => {
    if (!text) return [0, 0, 0, 0];
    // Simple deterministic pseudo-embedding based on string length and char codes
    const baseVal = text.length % 10 / 10;
    return [baseVal, 0.85, 0.42, 0.1];
  };

  return {
    searchParams,
    searchResults,
    executionTimeMs,
    isLoading,
    errorMessage,
    executeSearch,
    collectionName
  };
}

💡 Practical note: In a production setting, never expose direct browser connections to a Qdrant instance with write privileges or without authentication headers. Route your debugger requests through an internal API gateway or backend middleware that injects your Qdrant API key securely.


3. Building the Vector Query Input and Embedding Preview Component

A core requirement for debugging vector search is the ability to inspect what vector is actually being sent to Qdrant. If your embedding model truncates text or handles special characters poorly, your vector will drift.

Let's build QueryWorkbench.vue to allow developers to toggle between plain text queries and raw vector manipulation sliders.

<template>
  <div className="bg-slate-900 text-slate-100 p-6 rounded-xl shadow-2xl border border-slate-800">
    <div className="flex justify-between items-center mb-6">
      <h2 className="text-xl font-bold tracking-tight text-emerald-400">
        🔍 Qdrant RAG Search Debugger
      </h2>
      <div className="flex items-center space-x-2 text-sm text-slate-400">
        <span>Collection:</span>
        <span className="px-2 py-1 bg-slate-800 rounded font-mono text-emerald-300">
          {{ collectionName }}
        </span>
      </div>
    </div>

    <!-- Mode Selector -->
    <div className="flex space-x-4 mb-4">
      <button
        @click="searchParams.useManualVector = false"
        :class="['px-4 py-2 rounded-lg text-sm font-medium transition', !searchParams.useManualVector ? 'bg-emerald-600 text-white' : 'bg-slate-800 text-slate-400 hover:bg-slate-700']"
      >
        Text Query (Auto-Embed)
      </button>
      <button
        @click="searchParams.useManualVector = true"
        :class="['px-4 py-2 rounded-lg text-sm font-medium transition', searchParams.useManualVector ? 'bg-emerald-600 text-white' : 'bg-slate-800 text-slate-400 hover:bg-slate-700']"
      >
        Raw Vector Input (Manual)
      </button>
    </div>

    <!-- Input Form -->
    <div className="space-y-4">
      <div v-if="!searchParams.useManualVector">
        <label className="block text-sm font-medium text-slate-300 mb-1">
          Query Text
        </label>
        <textarea
          v-model="searchParams.queryText"
          rows="3"
          placeholder="e.g., How do I handle database migrations safely?"
          className="w-full bg-slate-950 border border-slate-700 rounded-lg p-3 text-slate-200 focus:ring-2 focus:ring-emerald-500 focus:outline-none font-mono text-sm"
        />
      </div>

      <div v-else class="space-y-2 bg-slate-950 p-4 rounded-lg border border-slate-800">
        <label className="block text-sm font-medium text-slate-300">
          Raw Vector Dimensions [4-DOF Float Array]
        </label>
        <div class="grid grid-cols-4 gap-3">
          <div v-for="(_, index) in searchParams.vectorInput" :key="index">
            <span class="text-xs text-slate-500 font-mono">dim[{{ index }}]</span>
            <input
              type="number"
              step="0.01"
              v-model.number="searchParams.vectorInput[index]"
              className="w-full bg-slate-900 border border-slate-700 rounded p-2 text-sm font-mono text-emerald-400"
            />
          </div>
        </div>
      </div>

      <!-- Execution Controls -->
      <div className="flex items-center justify-between pt-2">
        <div class="flex items-center space-x-4 text-sm text-slate-400">
          <div>
            <span>Limit: </span>
            <select v-model.number="searchParams.limit" class="bg-slate-950 border border-slate-700 rounded p-1 text-slate-200">
              <option :value="3">3</option>
              <option :value="5">5</option>
              <option :value="10">10</option>
            </select>
          </div>
          <div>
            <span>Threshold: </span>
            <input type="number" step="0.05" min="0" max="1" v-model.number="searchParams.scoreThreshold" class="w-20 bg-slate-950 border border-slate-700 rounded p-1 text-slate-200" />
          </div>
        </div>

        <button
          @click="executeSearch"
          :disabled="isLoading"
          class="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-semibold px-6 py-2.5 rounded-lg transition flex items-center space-x-2 disabled:opacity-50"
        >
          <span v-if="isLoading" class="animate-spin">⏳</span>
          <span>{{ isLoading ? 'Searching Qdrant...' : 'Run Query' }}</span>
        </button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRagDebugger } from '../composables/useRagDebugger';
const { searchParams, executeSearch, isLoading, collectionName } = useRagDebugger();
</script>

4. Implementing Advanced Payload Filtering Controls

One of the most insidious bugs in vector search occurs when filters are applied after vector scoring instead of during indexing traversal. Qdrant solves this with optimized payload indexes, but if your filter key doesn't match your payload schema or if your condition uses the wrong matching operator, your retrieval set will return empty.

Let's add a payload filter builder component to our Vue application:

<template>
  <div class="bg-slate-900 text-slate-100 p-6 rounded-xl shadow-2xl border border-slate-800 mt-6">
    <h3 class="text-lg font-semibold text-slate-200 mb-4 flex items-center justify-between">
      <span>🛡️ Payload Filter Inspector</span>
      <span class="text-xs font-mono text-emerald-400 bg-emerald-950/50 px-2.5 py-1 rounded border border-emerald-800/50">
        Qdrant Filter DSL Active
      </span>
    </h3>

    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
      <div>
        <label class="block text-sm font-medium text-slate-400 mb-1">Category Filter</label>
        <select
          v-model="searchParams.selectedCategory"
          class="w-full bg-slate-950 border border-slate-700 rounded-lg p-2.5 text-slate-200 text-sm focus:ring-2 focus:ring-emerald-500"
        >
          <option value="all">All Categories (No Filter)</option>
          <option value="infrastructure">Infrastructure</option>
          <option value="security">Security</option>
        </select>
      </div>

      <div>
        <label class="block text-sm font-medium text-slate-400 mb-1">Access Level Match</label>
        <select
          v-model="searchParams.accessLevel"
          class="w-full bg-slate-950 border border-slate-700 rounded-lg p-2.5 text-slate-200 text-sm focus:ring-2 focus:ring-emerald-500"
        >
          <option value="">Any</option>
          <option value="internal">Internal Only</option>
          <option value="public">Public</option>
        </select>
      </div>
    </div>

    <!-- Live DSL Preview Box -->
    <div class="mt-4">
      <span class="text-xs font-medium text-slate-500 uppercase tracking-wider">Generated Qdrant Filter Payload JSON:</span>
      <pre class="mt-1 bg-slate-950 p-3 rounded-lg text-xs font-mono text-emerald-400 overflow-x-auto border border-slate-800">{{ generatedFilterJson }}</pre>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useRagDebugger } from '../composables/useRagDebugger';

const { searchParams } = useRagDebugger();

const generatedFilterJson = computed(() => {
  const must = [];
  if (searchParams.selectedCategory !== 'all') {
    must.push({ key: 'category', match: { value: searchParams.selectedCategory } });
  }
  if (searchParams.accessLevel) {
    must.push({ key: 'access_level', match: { value: searchParams.accessLevel } });
  }
  return JSON.stringify(must.length > 0 ? { must } : {}, null, 2);
});
</script>

5. Crafting the Real-Time Results Inspector with Score Breakdown

Once Qdrant returns matching points, our debugger needs to display them clearly. Developers need to see the point ID, the exact cosine similarity score, the stored document payload, and the raw vector values associated with each result.

Let's build ResultsInspector.vue:

<template>
  <div class="bg-slate-900 text-slate-100 p-6 rounded-xl shadow-2xl border border-slate-800 mt-6">
    <div class="flex justify-between items-center mb-4">
      <h3 class="text-lg font-semibold text-slate-200">
        📊 Retrieval Results Inspector
      </h3>
      <div v-if="executionTimeMs > 0" class="text-xs font-mono text-slate-400">
        Executed in <span class="text-emerald-400 font-bold">{{ executionTimeMs }} ms</span> | 
        Found <span class="text-emerald-400 font-bold">{{ searchResults.length }}</span> matches
      </div>
    </div>

    <div v-if="errorMessage" class="bg-rose-950/50 border border-rose-800 text-rose-300 p-4 rounded-lg text-sm mb-4">
      <strong>Error executing search:</strong> {{ errorMessage }}
    </div>

    <div v-if="searchResults.length === 0 && !errorMessage" class="text-center py-12 text-slate-500 border border-dashed border-slate-800 rounded-lg">
      No search results loaded yet. Run a query above to inspect Qdrant retrieval scoring.
    </div>

    <div v-else class="space-y-4">
      <div
        v-for="result in searchResults"
        :key="result.id"
        class="bg-slate-950 border border-slate-800 rounded-lg p-4 hover:border-slate-700 transition"
      >
        <div class="flex items-center justify-between mb-2">
          <div class="flex items-center space-x-3">
            <span class="px-2 py-0.5 bg-slate-900 border border-slate-700 rounded text-xs font-mono text-slate-300">
              ID: {{ result.id }}
            </span>
            <span class="text-sm font-semibold text-slate-100">
              {{ result.payload.title }}
            </span>
          </div>

          <!-- Score Badge with Visual Indicator -->
          <div class="flex items-center space-x-2">
            <div class="w-24 bg-slate-900 rounded-full h-2.5 overflow-hidden border border-slate-800">
              <div
                class="bg-emerald-500 h-2.5 rounded-full"
                :style="{ width: `${Math.max(0, Math.min(100, result.score * 100))}%` }"
              ></div>
            </div>
            <span class="text-xs font-mono font-bold text-emerald-400">
              {{ result.score.toFixed(4) }}
            </span>
          </div>
        </div>

        <!-- Document Content -->
        <p class="text-sm text-slate-300 bg-slate-900/50 p-3 rounded border border-slate-800/60 mb-3">
          {{ result.payload.content }}
        </p>

        <!-- Metadata & Vector Accordion / Details -->
        <div class="flex flex-wrap gap-2 text-xs font-mono text-slate-400">
          <span class="bg-slate-900 px-2 py-1 rounded border border-slate-800">
            category: <strong class="text-slate-200">{{ result.payload.category }}</strong>
          </span>
          <span class="bg-slate-900 px-2 py-1 rounded border border-slate-800">
            access: <strong class="text-slate-200">{{ result.payload.access_level }}</strong>
          </span>
          <span v-if="result.vector" class="bg-slate-900 px-2 py-1 rounded border border-slate-800 text-slate-500">
            vector: [{{ result.vector.map(v => v.toFixed(2)).join(', ') }}]
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRagDebugger } from '../composables/useRagDebugger';
const { searchResults, executionTimeMs, errorMessage } = useRagDebugger();
</script>

6. Adding Hybrid Search (Sparse-Dense) Debugging Capabilities

Modern RAG pipelines increasingly rely on Hybrid Search, combining dense vector embeddings with sparse keyword indices (like BM25 or SPLADE) handled directly inside Qdrant via sparse vectors.

When debugging hybrid search, you need to understand how score fusion (RRF - Reciprocal Rank Fusion or linear combination) affects your final ordering.

Let's extend our Vue composable to support Qdrant's prefetch and fusion query syntax.

// Additive snippet for useRagDebugger.js supporting multi-stage query fusion
const executeHybridSearch = async () => {
  isLoading.value = true;
  try {
    // Qdrant supports prefetch queries for hybrid dense + sparse retrieval
    const response = await client.query(collectionName.value, {
      prefetch: [
        {
          query: [0.1, 0.8, 0.4, 0.0], // Dense vector branch
          limit: 10,
        },
        {
          query: { indices: [1, 3], values: [1.5, 2.0] }, // Sparse vector branch (BM25 simulation)
          limit: 10,
        }
      ],
      query: {
        fusion: 'rrf' // Reciprocal Rank Fusion
      },
      limit: searchParams.limit,
      with_payload: true
    });
    searchResults.value = response.points;
  } catch (err) {
    errorMessage.value = err.message;
  } finally {
    isLoading.value = false;
  }
};

🧠 The important part: Reciprocal Rank Fusion (rrf) is immune to score scale discrepancies between sparse and dense models because it ranks documents based on their ordinal position rather than raw floating-point distance numbers. If your hybrid search is returning garbage results, switching your debugger to inspect individual prefetch branch scores will immediately show whether your sparse keyword index or your dense semantic index is failing.


7. Visualizing Latency and Performance Bottlenecks

In production RAG systems, retrieval latency directly impacts user experience. If your vector search takes over 200ms, your chat interface feels sluggish.

Let's add a telemetry bar to our Vue debugger that monitors:

  • Qdrant internal search execution time
  • Payload filtering overhead
  • Network round-trip duration

Create TelemetryMonitor.vue:

<template>
  <div class="bg-slate-900 text-slate-100 p-4 rounded-xl shadow-2xl border border-slate-800 mt-6 flex items-center justify-between text-xs font-mono">
    <div class="flex items-center space-x-6">
      <div>
        <span class="text-slate-500">ENGINE:</span>
        <span class="text-emerald-400 font-bold ml-1">QDRANT v1.12</span>
      </div>
      <div>
        <span class="text-slate-500">INDEX TYPE:</span>
        <span class="text-emerald-400 font-bold ml-1">HNSW (M=16, ef_construct=100)</span>
      </div>
      <div>
        <span class="text-slate-500">METRIC:</span>
        <span class="text-emerald-400 font-bold ml-1">Cosine</span>
      </div>
    </div>
    <div>
      <span class="text-slate-500">CLIENT STATUS:</span>
      <span class="text-emerald-400 font-bold ml-1">🟢 Connected (Port 6333)</span>
    </div>
  </div>
</template>

Production Hardening and Security Considerations

When you take your RAG Search Debugger out of your local development environment and deploy it to an internal staging cluster, keep these production practices in mind:

  1. Network Boundary Protection: Never expose Qdrant's raw HTTP port (6333) or gRPC port (6334) to the public internet. Ensure your Vue frontend talks exclusively through a secured backend API route or a service mesh with Mutual TLS (mTLS).
  2. Qdrant API Key Authentication: Enable API keys in your Qdrant configuration (QDRANT__SERVICE__API_KEY) and pass them via the api-key header in your JavaScript client configuration:
    const client = new QdrantClient({
      url: 'https://qdrant.internal.company.com',
      apiKey: process.env.VUE_APP_QDRANT_API_KEY
    });
    
  3. Payload Sanitization: When displaying complex document payloads in your Vue inspector, ensure HTML or markdown injection vectors from retrieved documents are properly sanitized before rendering.

Putting It All Together in App.vue

Now, let's assemble our full dashboard inside src/App.vue:

<template>
  <main class="min-h-screen bg-slate-950 text-slate-100 p-8">
    <div class="max-w-5xl mx-auto">
      <header class="mb-8">
        <h1 class="text-3xl font-extrabold tracking-tight text-white">
          RAG Search Control Center
        </h1>
        <p class="text-sm text-slate-400 mt-1">
          Interactive debugging workbench for Qdrant vector retrieval, payload filtering, and relevance scoring.
        </p>
      </header>

      <QueryWorkbench />
      <PayloadFilterInspector />
      <ResultsInspector />
      <TelemetryMonitor />
    </div>
  </main>
</template>

<script setup>
import QueryWorkbench from './components/QueryWorkbench.vue';
import PayloadFilterInspector from './components/PayloadFilterInspector.vue';
import ResultsInspector from './components/ResultsInspector.vue';
import TelemetryMonitor from './components/TelemetryMonitor.vue';
</script>

Final Perspective

Debugging vector search by staring at terminal logs is an exercise in frustration. By pairing Vue's reactive composition model with Qdrant's lightning-fast REST and filtering APIs, you gain immediate visual feedback into how semantic similarity, score thresholds, and payload filters interact in real time.

The next time your RAG pipeline retrieves the wrong context, don't guess—fire up your debugger, tweak your vector dimensions, inspect your payload filter DSL, and see precisely what your database sees.

Post a Comment

Previous Post Next Post