Skip to main content
Querying is where Databases pay off. You’ve stored your documents, your embeddings are built, and now your agents and workflows need to retrieve the right information at the right time. Scout gives you three search modes — semantic, keyword, and hybrid — along with metadata filters and tunable thresholds so you can dial in exactly the results you need.

Query Modes

Semantic search converts your query into a vector embedding and returns documents whose embeddings are closest in vector space. It finds relevant content even when the user’s words don’t appear verbatim in the document.
Use semantic search for conversational interfaces, synonym-rich content, and queries where users express intent in their own words.

Keyword Search (BM25)

Keyword search uses the BM25 algorithm to find documents containing exact keyword matches. It’s the same mechanism behind traditional full-text search.
Use keyword search when users search for specific identifiers, error codes, product names, or other terms where exact matching matters more than semantic similarity. Hybrid search runs both a semantic pass and a keyword pass, then merges and re-ranks the results using Reciprocal Rank Fusion (RRF). You get the precision of keyword matching alongside the conceptual coverage of vector search in a single ranked result set.
Hybrid search is the recommended default for most production applications. It handles mixed query styles — proper nouns blended with natural language — better than either mode alone.

Query Parameters

string
required
The query string. In workflow blocks this supports Jinja templating, for example {{inputs.user_question}}.
number
default:"0.35"
Minimum relevance threshold. Results below this score are excluded. Range is 0.0 to 1.0. See Tuning min_similarity for guidance.
integer
default:"10"
Maximum number of results to return.
When true, enables hybrid mode — results from semantic and keyword passes are fused using RRF.
number
default:"0.5"
Controls the balance between semantic and keyword search in hybrid mode. 0.0 = pure keyword, 1.0 = pure semantic. Ignored when hybrid_search is false.
array
Filter results by metadata column values. See Filtering by Metadata for the full syntax.

Querying via Workflow Blocks

Add a Query Database Table block to any workflow to search your data at runtime.

Configuration

Example Block Configuration

Working with Query Results

The block returns an array of result objects. Each result contains a details object with relevance scores and a record object with the document’s fields:
number
Distance from the query in vector space. Lower values indicate higher similarity. 0.0 is identical; 1.0 is completely unrelated. Present on all results.
number
Fused relevance score when hybrid_search: true. Higher is better. null for pure semantic queries.
string
The unique document identifier.
object
All metadata fields stored on the document, keyed by column name.
Access results in downstream blocks with Jinja:
Handle empty results gracefully:

Querying via API

Basic Semantic Query

Hybrid Search Query

Using the Python SDK

Using the TypeScript SDK

Filtering by Metadata

Metadata filters let you narrow results using column values before or after the similarity ranking step. Filters use a JSON array with the format ["column_id", "operator", "value"].

Available Operators

Filter Examples

Single column filter:
Date range:
Multiple categories:
Case-insensitive title match:
Combined conditions:

Using Filters in Workflow Blocks

Apply filters dynamically with Jinja templating:
For conditional filter logic:

Tuning min_similarity

The min_similarity threshold cuts off results below a relevance score. Start with 0.5 and adjust based on what you observe. Practical guidance:
  • Use 0.3–0.4 for exploratory search or content discovery.
  • Use 0.5–0.6 as a general-purpose default for production.
  • Use 0.7–0.8 for technical documentation where precision matters.
  • Use 0.8+ when you need near-exact semantic matches.

Tuning Alpha (Hybrid Mode)

The alpha parameter shifts the balance between semantic and keyword scoring in hybrid mode. When to adjust:
  • Lower alpha (0.2–0.4) for technical docs with specific identifiers and exact terms.
  • Medium alpha (0.5) for general knowledge bases — start here.
  • Higher alpha (0.7–0.9) for natural language conversations and content discovery.

Using Databases with Agents

1. Enable Databases Tools

In your agent’s Tools tab, enable the Databases query capability.

2. Add an Instruction Snippet

3. Prompt Examples

  • “Find troubleshooting steps for SSO login failures from the IT docs table.”
  • “Search only category = policy and summarize PTO policy changes since Jan. 1.”
  • “Query the sales enablement table for pricing objection handling and give me three approved responses.”

Common Query Patterns

Find Similar Documents

Recent Tutorials Only

Exclude Drafts

Troubleshooting

Getting no results
  • Lower min_similarity — try 0.3 to cast a wider net.
  • Confirm your table has indexed documents by checking the row count in Scout Studio.
  • Try a simple, general search term to confirm the data is reachable.
  • Temporarily remove filters to check whether a filter condition is too restrictive.
Too many irrelevant results
  • Raise min_similarity to 0.6 or higher.
  • Add metadata filters to scope results to the right category or status.
  • Lower alpha toward 0.3 if your query uses specific terms that should match exactly.
Missing an obvious match
  • Confirm the document is in the correct table.
  • Check for typos in filter values — Eq and In operators are case-sensitive. Use IGlob for case-insensitive text matching.
  • Try hybrid search if you’ve been using semantic-only.
  • Re-sync your data source if the record was added recently and may not be indexed yet.
Low scores on relevant results vector_distance values above 0.5 generally indicate weak semantic alignment. This often means:
  • Your query phrasing doesn’t match how the content is written.
  • The content is too short or generic to embed well.
  • Consider enriching your documents with more descriptive text and re-syncing.

Best Practices

  1. Start with defaultsmin_similarity: 0.5, hybrid_search: true, alpha: 0.5. Adjust from there based on observed results.
  2. Prefer hybrid search — it outperforms pure semantic or pure keyword for the vast majority of real-world queries.
  3. Use metadata filters — scoping to category, date, or status dramatically improves precision without sacrificing recall within the relevant subset.
  4. Write rich content — comprehensive, descriptive text in the content field produces better embeddings and more accurate retrieval.
  5. Test with real queries — use actual user questions (not synthetic ones) to tune thresholds and filter configurations.

Next Steps

Databases Overview

Understand the Databases data model and when to use it.

Creating Databases

Set up schemas optimized for search quality.

Sources

Keep database data fresh with automated syncs.