When to Use Which Query (v1)

Aito provides different query types for different use cases. This guide helps you choose the right one.

Using the v2 engine? See Which Query Type? (v2). This page covers the v1 API — some operations here (e.g. the _similarity endpoint) do not exist in v2, where similarity is the in-query $nearest / $knn operator instead.

See it in action: Explore the demo workbook to run these query types yourself.

Quick Reference

You want to...UseWhyExample
Filter data_searchDeterministic, exact matchesFind products under $5
Predict a category_predictProbabilistic classificationPredict product tags
Rank best options_recommendOptimizes for a goalRecommend products to buy
Estimate a number_estimateK-NN regressionPredict prices
Find similar items_similarityDistance-based rankingFind related products

Search vs Predict

Use Search when you need exact, deterministic results:

  • Filtering by specific values
  • Retrieving known records
  • Boolean conditions (AND, OR)

Use Predict when you want probabilistic answers:

  • "What category is this likely to be?"
  • "What tag should this product have?"
  • Classification based on patterns in data

Example: Finding vs Predicting Products

Search - Find products in a specific category:

{
  "from": "products",
  "where": {
    "category": "100"
  },
  "limit": 5
}

Try in Playground

Predict - Predict the most likely category for a new product:

{
  "from": "products",
  "where": {
    "name": "Organic Fair Trade Coffee 500g"
  },
  "predict": "category"
}

Try in Playground

Predict vs Recommend

Use Predict when you want to classify or complete a single field:

  • "Which processor should handle this invoice?"
  • "What tags describe this product?"
  • Predicting unknown values based on known fields

Use Recommend when you want to rank options that optimize a goal:

  • "Which product should I show this user to maximize purchase?"
  • "Which search result is most likely to be clicked?"
  • Ranking items by predicted outcome likelihood

Example: Classification vs Ranking

Predict - Classify which processor should handle an invoice:

{
  "from": "invoices",
  "where": {
    "ProductName": "Cloud Services (AWS)",
    "Description": "For IT Department"
  },
  "predict": "Processor"
}

Try in Playground

Recommend - Rank products by purchase likelihood for a user:

{
  "from": "impressions",
  "where": {
    "context.user": "0"
  },
  "recommend": "product",
  "goal": { "purchase": true }
}

Try in Playground

Predict vs Estimate

Use Predict for categorical values (classification):

  • Discrete outcomes: categories, labels, tags
  • Returns probability distribution over possible values

Use Estimate for numeric values (regression):

  • Continuous values: prices, quantities, durations
  • Returns a single numeric estimate with K-NN

Example: Category vs Price

Predict - Predict product category (categorical):

{
  "from": "products",
  "where": {
    "name": "Rye bread"
  },
  "predict": "category"
}

Try in Playground

Estimate - Estimate product price (numeric):

{
  "from": "price_history",
  "where": {
    "product_id": "2000818700008",
    "category": "100",
    "is_weekend": false
  },
  "estimate": "sale_price"
}

Try in Playground

Recommend vs Similarity

Use Recommend when you have behavioral data with outcomes:

  • "Show products that maximize purchase likelihood"
  • Requires a goal (the outcome to optimize)
  • Uses conversion patterns from training data

Use Similarity when you want content-based matching:

  • "Find products similar to this one"
  • No goal needed - purely based on feature similarity
  • Works without behavioral data

Example: Behavioral vs Content-Based

Recommend - Products likely to be purchased (behavioral):

{
  "from": "impressions",
  "where": {
    "context.user": "veronica"
  },
  "recommend": "product",
  "goal": { "purchase": true }
}

Try in Playground

Similarity - Products with similar attributes (content):

{
  "from": "products",
  "similarity": {
    "name": "Juhla Mokka coffee 500g sj",
    "category": "108"
  },
  "limit": 5
}

Try in Playground

Decision Tree

                    What do you need?
                          │
          ┌───────────────┼───────────────┐
          │               │               │
    Exact matches    ML prediction   Find similar
          │               │               │
       _search            │          _similarity
                          │
          ┌───────────────┼───────────────┐
          │               │               │
    Classify/Label   Rank options   Estimate number
          │               │               │
       _predict      _recommend      _estimate

Summary

QueryInputOutputUse When
_searchFilter conditionsMatching rowsYou know exactly what you're looking for
_predictContext fieldsProbability distributionYou need to classify or predict a category
_recommendContext + goalRanked itemsYou want to optimize for an outcome
_estimateContext fieldsNumeric valueYou need to predict a continuous number
_similarityReference objectSimilar itemsYou want content-based matching
_relatePropositionCorrelationsYou want to discover patterns