Semantic Search

In this tutorial, you'll learn how to perform semantic searches in the SnackPrompt AI Engine Knowledge Base.

Unlike keyword search (which looks for exact matches), semantic search understands the meaning of your question.

Example:

  • Traditional search: "price product" → only finds documents with those exact words

  • Semantic search: "how much does it cost?" → finds documents about prices, values, costs, etc.

Prerequisites

  • A valid tenant_id

  • Data already ingested in the Knowledge Base (see Ingesting Data)

curl -X POST https://api-integrations.snackprompt.com/v1/kb/search \
  -H "Content-Type: application/json" \
  -d '{
    "query": "what are the return policies?",
    "filters": {
      "tenant_id": "YOUR_TENANT_ID"
    },
    "limit": 5
  }'

Parameters

Parameter
Type
Required
Description

query

string

Yes

Your search text

filters

object

Yes

Filters (includes required tenant_id)

limit

number

No

Maximum number of results (default: 10)

Step 2: Understand the Similarity Score

Each result includes a score from 0 to 1:

How to Interpret the Score

Score
Interpretation

0.90 - 1.00

Very relevant - almost exact match

0.75 - 0.89

Relevant - good semantic match

0.60 - 0.74

Moderate - related to the topic

< 0.60

Low - possibly not relevant

Tip: In production, consider filtering results with scores below 0.6 or 0.7.

Step 3: Use Filters to Refine Results

Filter by Specific Elemental

Search only in a specific document/table:

Filter by Tags

Search only in documents with certain tags:

Note: When multiple tags are provided, the logic is OR (any of them).

Filter by Source Type

Possible values for source:

  • elemental - SnackPrompt tables

  • document - Documents

  • file - Uploaded files

Available Filters

Filter
Type
Required
Description

tenant_id

string

YES

Tenant ID (isolation)

elemental_id

string

No

Filter by specific elemental

user_id

string

No

Filter by user

tag_ids

string[]

No

Filter by tag IDs (OR)

tag_names

string[]

No

Filter by tag names (OR)

source

string

No

Source type

type_name

string

No

Elemental type (Table, Document)

category_name

string

No

Elemental category

Combining Filters

Multiple filters are combined with AND logic:

This example searches for "prices" in:

  • Elementals (not documents or files) AND

  • With tag "Products" OR "Sales"

Tips for Better Results

1. Be Specific in Your Query

2. Use Natural Language

3. Limit the Results

Fewer results = more relevant results.

4. Use Filters When Possible

If you know where the information is, use filters to improve precision:

Next Steps

Now that you've mastered semantic search:

  1. Chat with your Data - Get elaborate answers with AI

  2. Filter by Tags - Advanced filtering techniques


Estimated time: 10 minutes ✅

Last updated

Was this helpful?