# **AI Dataset Search** (`dtrungtin/ai-dataset-search`) Actor

The actor lets you query any dataset using **plain English** instead of code. Point it at a dataset — for example the output of a scraper run — describe what you're looking for ("videos about race day at the Belgian Grand Prix", "items with more than 100k plays"), and it returns the matching items.

- **URL**: https://apify.com/dtrungtin/ai-dataset-search.md
- **Developed by:** [Tin](https://apify.com/dtrungtin) (community)
- **Categories:** AI
- **Stats:** 3 total users, 1 monthly users, 65.2% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.10 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## AI Dataset Search

### What does AI Dataset Search do?

**AI Dataset Search** lets you query any [Apify dataset](https://docs.apify.com/platform/storage/dataset) using **plain English** instead of code. Point it at a dataset — for example the output of a scraper run — describe what you're looking for ("videos about race day at the Belgian Grand Prix", "posts by verified authors", "items with more than 100k plays"), and it returns the matching items **ranked by relevance**.

Under the hood, an AI model inspects the dataset's structure and turns your prompt into a search plan: fuzzy text search with [Fuse.js](https://www.fusejs.io/) across the most relevant fields, plus exact and numeric filters. You don't need to know the dataset's field names — the Actor figures them out for you.

Running on the Apify platform gives you API access, scheduling, integrations (Make, Zapier, webhooks), and run monitoring out of the box.

### Why use AI Dataset Search?

- **No query language to learn** — describe what you want in natural language.
- **Works with any dataset** — the schema is inferred automatically from the data, including nested fields.
- **Typo-tolerant** — fuzzy matching finds "Belgain GP" even when you meant "Belgian GP".
- **Ranked results** — every result carries a match score, best matches first.
- **Composable** — chain it after any scraper: scrape first, then search the results with a prompt.

### How to use AI Dataset Search

1. Open the Actor and go to the **Input** tab.
2. Paste the **dataset ID or URL** of the dataset you want to search — or, instead, enter an **Actor** (e.g. `apify/instagram-scraper`) to search the dataset of its latest successful run.
3. Write a **search prompt** describing what to find.
4. Set your **OpenAI API key** as the `OPENAI_API_KEY` environment variable (the Actor uses an OpenAI model to plan the search).
5. Click **Start** and open the **Output** tab when the run finishes.

### Input

| Field | Type | Description |
| --- | --- | --- |
| `datasetId` | string | Dataset ID (e.g. `wqoOfQSYVPInyFZhd`) or a dataset URL from the API or Console. |
| `actorId` | string | Alternative to `datasetId`: an Actor ID, `username/actor-name`, or Store URL — the default dataset of its latest successful run is searched. Ignored when `datasetId` is set. |
| `prompt` | string | Natural-language description of what to find. **Required.** |
| `maxItems` | integer | Maximum number of items loaded from the dataset (default `5000`). |

Provide either `datasetId` or `actorId`.

```json
{
    "datasetId": "wqoOfQSYVPInyFZhd",
    "prompt": "Find TikTok videos about race day at the Belgian Grand Prix",
    "maxItems": 5000
}
```

### Output

Matching items are pushed to the default dataset, sorted by relevance. Each item is the original dataset item plus a `score` field (lower = better match). You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

```json
{
    "score": 0.0016,
    "caption": "Come with us to tour F1 hospitality! #f1 #formula1 #f1spa #spagp ...",
    "url": "https://www.tiktok.com/@.../video/...",
    "author": { "uniqueId": "...", "verified": true },
    "stats": { "playCount": 518100, "diggCount": 39300 }
}
```

The columns after `score` depend entirely on the dataset you search — the Actor preserves the original items untouched.

### How much does it cost to search a dataset?

Each run makes **one small OpenAI API call** (the search planning step) — typically a fraction of a cent with a mini-class model — plus standard Apify platform usage for the compute. Searching thousands of items completes in seconds, so runs stay well within the free tier limits of both platforms for typical use.

### Tips for better results

- **Be specific in the prompt.** "Videos mentioning Mercedes with over 100k plays" gives the planner both a search phrase and a numeric filter to work with.
- **Limit `maxItems`** if you only need a quick answer from a huge dataset — fewer items means faster runs.
- **Check the run log.** The Actor logs the generated search plan (`PLAN`), so you can see exactly which fields were searched and which filters were applied.
- The Actor returns at most 100 top results per run.

### FAQ and support

**Which datasets can I search?** Any dataset your Apify account can read: your own runs' outputs or publicly accessible datasets.

**Does it modify the source dataset?** No — the source dataset is only read; results go to the run's own output dataset.

**Is my data sent anywhere?** Only the dataset's *field structure* with one example value per field is sent to OpenAI for planning — not the full dataset contents.

Found a bug or missing a feature? Please open an issue on the Actor's **Issues** tab — feedback is welcome. Custom solutions (different search backends, embedding-based semantic search, other LLM providers) can be built on request.

# Actor input Schema

## `datasetId` (type: `string`):

The Apify dataset to search. Accepts a dataset ID (e.g. "wqoOfQSYVPInyFZhd") or a dataset URL from the API or Console. Leave empty to use an Actor's latest run instead (see below).

## `actorId` (type: `string`):

Alternative to Dataset ID: an Actor whose latest successful run's default dataset will be searched. Accepts an Actor ID, "username/actor-name", or a Store URL (e.g. "apify/instagram-scraper"). Ignored when Dataset ID is set.

## `prompt` (type: `string`):

Natural language description of what to find in the dataset, e.g. 'products under $50 with rating above 4'. An AI model converts this into a fuse search plan.

## `maxItems` (type: `integer`):

Maximum number of items to load from the dataset for searching.

## Actor input object example

```json
{
  "datasetId": "FprteYhzGTNUWPS7M",
  "prompt": "Find items matching...",
  "maxItems": 5000
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "prompt": "Find items matching..."
};

// Run the Actor and wait for it to finish
const run = await client.actor("dtrungtin/ai-dataset-search").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "prompt": "Find items matching..." }

# Run the Actor and wait for it to finish
run = client.actor("dtrungtin/ai-dataset-search").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "prompt": "Find items matching..."
}' |
apify call dtrungtin/ai-dataset-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=dtrungtin/ai-dataset-search",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/VafjgSHavOWSEqCCX/builds/FbscMtGZtIfHpuHRi/openapi.json
