---
title: "Query"
description: "Query vectors in a knowledge base by id, text, or vector."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/kb/query"
---
# Query

> Query vectors in a knowledge base by id, text, or vector.

<block-meta block="Yes" channels="Any" folder="kb" group="Knowledge Base" groupTo="/build/workflows/blocks/kb" icon="i-lucide-search" pipe="Value" scope="Any" tool="Yes" type="kb.query">



</block-meta>

**Query** (canvas label **KB Query**) searches a [knowledge base](https://docs.vettero.com/data/knowledge-bases). **By text** matches similar meaning (not exact keywords). **By ID** loads one vector. **By vector** searches with an embedding you already have.

For **By text** and **By vector**, set **Top K** and optional metadata filters. Filters follow the store’s meta fields when **Strict** is on.

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Knowledge base
      </strong>
    </td>
    
    <td>
      Store to search (required)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Query mode
      </strong>
    </td>
    
    <td>
      <strong>
        By ID
      </strong>
      
      , <strong>
        By text
      </strong>
      
       (default), or <strong>
        By vector
      </strong>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Vector ID
      </strong>
    </td>
    
    <td>
      Shown in By ID — id of the vector
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Text
      </strong>
    </td>
    
    <td>
      Shown in By text — search phrase
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Vector (comma-separated)
      </strong>
    </td>
    
    <td>
      Shown in By vector — embedding values
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Top K
      </strong>
    </td>
    
    <td>
      Shown in By text / By vector — how many hits to return. Default <strong>
        10
      </strong>
      
      , 1–1000
    </td>
  </tr>
  
  <tr>
    <td>
      Metadata filter
    </td>
    
    <td>
      Shown in By text / By vector — optional conditions on metadata
    </td>
  </tr>
</tbody>
</table>

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after the search returns
    </td>
  </tr>
</tbody>
</table>

## Pipe schema

The next block reads this on the data pipe (`pipe.value`).

**By ID** — one result, or null if missing:

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      text
    </td>
    
    <td>
      Vector id
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        metadata
      </code>
    </td>
    
    <td>
      object
    </td>
    
    <td>
      Metadata (strict fields, or loose plus <code>
        source
      </code>
      
      , <code>
        sourceId
      </code>
      
      , <code>
        sourceType
      </code>
      
      , <code>
        text
      </code>
      
      )
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        values
      </code>
    </td>
    
    <td>
      list of numbers
    </td>
    
    <td>
      Embedding values
    </td>
  </tr>
</tbody>
</table>

**By text** / **By vector** — an object:

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        results
      </code>
    </td>
    
    <td>
      list
    </td>
    
    <td>
      Hits, best match first
    </td>
  </tr>
</tbody>
</table>

Each hit includes:

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      text
    </td>
    
    <td>
      Vector id
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pageContent
      </code>
    </td>
    
    <td>
      text
    </td>
    
    <td>
      Indexed text
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        score
      </code>
    </td>
    
    <td>
      number
    </td>
    
    <td>
      Similarity score
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        metadata
      </code>
    </td>
    
    <td>
      object
    </td>
    
    <td>
      Metadata for that chunk
    </td>
  </tr>
</tbody>
</table>

## Use case

- Ground a reply on product docs or FAQs before sending [Text](https://docs.vettero.com/build/workflows/blocks/out/text).
- Look up a known vector id after an earlier [Upsert](https://docs.vettero.com/build/workflows/blocks/kb/upsert).
- Filter by locale or product when the store is **Strict**.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
