# Fuzzy Search Dataset Actor (`dtrungtin/fuzzy-search-dataset-actor`) Actor

Search any Apify dataset using typo-tolerant fuzzy matching.

- **URL**: https://apify.com/dtrungtin/fuzzy-search-dataset-actor.md
- **Developed by:** [Tin](https://apify.com/dtrungtin) (community)
- **Categories:** Other, Developer tools
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.001 / 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 a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## Fuzzy Search Dataset Actor

**Search any Apify dataset using typo-tolerant fuzzy matching.** Point this Actor at an existing dataset, provide a query, and get back ranked results — even when spellings are imperfect. Try it directly in [Apify Console](https://console.apify.com/).

### What does Fuzzy Search Dataset do?

This Actor loads records from any Apify dataset and runs a fuzzy full-text search across one or more fields. It handles typos, partial matches, and word-order variations automatically. For example, searching `"iphon pro mx"` can still return results for `"iPhone 15 Pro Max"`.

It's ideal for post-processing scraped data — after collecting a large dataset with another Actor, use this one to instantly build a search layer on top of it without any external infrastructure.

### Why use Fuzzy Search Dataset?

- **No search engine needed** — works directly on any Apify dataset without Elasticsearch, Algolia, or similar tools
- **Typo-tolerant** — handles misspellings, abbreviations, and partial queries out of the box
- **Multi-field search** — search across `title`, `description`, `brand`, nested fields like `product.name`, or any combination
- **Tunable relevance** — control strictness, field weights, and minimum match length to fit your data
- **Automation-ready** — trigger via API, schedule it, or chain it after a scraping Actor in a workflow

### How to use Fuzzy Search Dataset

1. **Run a scraping Actor** to build the source dataset (or use any existing dataset you already have in Apify Console).
2. **Copy the dataset ID** from the dataset URL or the Storage section of Apify Console.
3. **Open this Actor** and paste the dataset ID into the **Dataset ID** field.
4. **Enter your search query** and choose which fields to search.
5. **Run the Actor** — results are written to its output dataset, ranked by relevance score.

### Input

Configure the Actor in the **Input** tab or pass a JSON object via the API.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `datasetId` | string | ✅ | — | ID of the Apify dataset to search |
| `query` | string | ✅ | — | Text to search for |
| `fields` | array of strings | | `["title"]` | Dataset fields to search (supports dot notation for nested fields) |
| `limit` | integer | | `20` | Maximum number of results to return (1–1000) |
| `threshold` | number | | `0.35` | Fuzzy strictness — `0.0` = exact only, `1.0` = match anything |
| `ignoreLocation` | boolean | | `true` | Allow matches anywhere in the text, not just at the start |
| `minMatchCharLength` | integer | | `2` | Minimum characters in a token before it counts as a match |
| `includeScore` | boolean | | `true` | Attach a relevance score to each result (lower = better match) |
| `includeMatches` | boolean | | `false` | Include matched text ranges — useful for keyword highlighting |
| `extendedSearch` | boolean | | `false` | Enable advanced query syntax (`^starts-with`, `!exclude`, `=exact`) |
| `weights` | object | | — | Per-field importance weights, e.g. `{"title": 0.7, "description": 0.3}` |

**Example input:**

```json
{
    "datasetId": "UoYaa1QjGdgdJrSHA",
    "query": "iphon pro max",
    "fields": ["title", "description"],
    "limit": 10,
    "threshold": 0.35,
    "weights": {
        "title": 0.8,
        "description": 0.2
    }
}
````

### Output

Results are pushed to the Actor's default dataset as a single object containing the query, total result count, and an array of ranked matches.

**Example output:**

```json
{
    "query": "iphon pro max",
    "totalResults": 3,
    "results": [
        {
            "rank": 1,
            "score": 0.04,
            "item": {
                "title": "Apple iPhone 15 Pro Max",
                "description": "6.7-inch Super Retina XDR display, A17 Pro chip",
                "brand": "Apple",
                "price": 1199
            }
        },
        {
            "rank": 2,
            "score": 0.18,
            "item": {
                "title": "iPhone 14 Pro Max",
                "description": "48MP main camera, Dynamic Island",
                "brand": "Apple",
                "price": 999
            }
        }
    ]
}
```

You can download results in JSON, CSV, Excel, or HTML from the dataset tab in Apify Console or via the [Apify API](https://docs.apify.com/api/v2).

### Output data fields

| Field | Format | Description |
|---|---|---|
| `query` | text | The search query that was used |
| `totalResults` | number | Number of results returned |
| `results[].rank` | number | 1-based position in results (1 = best match) |
| `results[].score` | number | Relevance score (0.0 = perfect match, 1.0 = no match) |
| `results[].item` | object | Full original record from the source dataset |

### Tips and advanced options

**Tuning the threshold:**

- `0.2` — strict, good for product codes and exact names
- `0.35` — balanced (default), works well for product titles and descriptions
- `0.6` — loose, useful for free-text fields or short queries

**Multi-field search with weights:**

To boost title matches above description matches, set `weights` to `{"title": 0.8, "description": 0.2}`. Weights must sum to 1.0 across all searched fields.

**Advanced query syntax** (when `extendedSearch` is enabled):

| Syntax | Meaning | Example |
|---|---|---|
| `=iphone` | Exact match | `=iPhone 15` |
| `^apple` | Starts with | `^Apple` |
| `!samsung` | Exclude | `!Samsung` |
| `'pro` | Includes token | `'pro` |

**Performance:** The Actor loads the entire dataset into memory. For datasets over 100k records, consider filtering the source dataset first or increasing the Actor's memory allocation.

### Pricing / Cost estimation

This Actor processes data in-memory without using a browser or proxy, so compute costs are low. A typical run over 10,000 records completes in under 30 seconds. Apify provides a [free tier](https://apify.com/pricing) sufficient for many use cases.

### FAQ and support

**Is this legal?** This Actor only reads from datasets you own or have access to on the Apify platform. It does not scrape any external websites.

**Can I use this with datasets from other Actors?** Yes — as long as you have access to the dataset ID, this Actor can read it.

**The results are empty or not what I expected.** Try raising the `threshold` value (e.g. to `0.5`), enabling `ignoreLocation`, or adding more fields to the `fields` array.

**Found a bug or want a feature?** Open an issue in the Issues tab on this Actor's page. Custom solutions are also available — reach out via the Apify platform.

### Resources

- [Apify SDK documentation](https://docs.apify.com/sdk/js)
- [Apify Platform documentation](https://docs.apify.com/platform)
- [Join the Apify developer community on Discord](https://discord.com/invite/jyEM2PRvMU)

# Actor input Schema

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

The Apify dataset ID that contains the records you want to search. You can find this in the dataset URL or in Apify Console. Example: 'abc123DEF456'.

## `query` (type: `string`):

The text users want to search for. Fuzzy search allows typos and partial matches. Example: searching for 'iphon pro' can still match 'iPhone 15 Pro Max'.

## `fields` (type: `array`):

List of dataset fields to search in. You can search multiple fields at the same time. Examples: 'title', 'description', 'brand', 'category', or nested fields like 'product.name'.

## `limit` (type: `integer`):

Maximum number of search results returned. Lower values improve performance. Recommended: 10 to 100.

## `threshold` (type: `number`):

Controls how strict the fuzzy search is. Lower values require more accurate matches. Higher values allow more typos and loose matching. Recommended values: 0.2 = strict, 0.35 = balanced, 0.6 = very loose.

## `ignoreLocation` (type: `boolean`):

When enabled, matches can appear anywhere inside the text. Example: searching 'pro' can match both 'iPhone Pro' and 'Professional Camera'. Recommended: enabled.

## `minMatchCharLength` (type: `integer`):

Minimum number of characters required before fuzzy considers a match. Helps reduce noisy results for very short queries. Recommended: 2 or 3.

## `includeScore` (type: `boolean`):

Adds a relevance score to each result. Lower scores mean better matches. Useful for debugging, sorting, or displaying search confidence.

## `includeMatches` (type: `boolean`):

Returns detailed information about which text fragments matched the query. Useful for highlighting matched keywords in a frontend application.

## `extendedSearch` (type: `boolean`):

Enables Fuzzy advanced query syntax. Examples: '^apple' = starts with apple, '!samsung' = exclude samsung, '=iphone' = exact match. Recommended for advanced users only.

## `weights` (type: `object`):

Optional JSON object that controls which fields are more important during ranking. Higher weight means higher priority in search results. Example: {"title": 0.7, "description": 0.2, "brand": 0.1}

## Actor input object example

```json
{
  "fields": [
    "title"
  ],
  "limit": 20,
  "threshold": 0.35,
  "ignoreLocation": true,
  "minMatchCharLength": 2,
  "includeScore": true,
  "includeMatches": false,
  "extendedSearch": false
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("dtrungtin/fuzzy-search-dataset-actor").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("dtrungtin/fuzzy-search-dataset-actor").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 '{}' |
apify call dtrungtin/fuzzy-search-dataset-actor --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Fuzzy Search Dataset Actor",
        "description": "Search any Apify dataset using typo-tolerant fuzzy matching.",
        "version": "0.0",
        "x-build-id": "6Me8viIBc2t2TyVjk"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/dtrungtin~fuzzy-search-dataset-actor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-dtrungtin-fuzzy-search-dataset-actor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/dtrungtin~fuzzy-search-dataset-actor/runs": {
            "post": {
                "operationId": "runs-sync-dtrungtin-fuzzy-search-dataset-actor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/dtrungtin~fuzzy-search-dataset-actor/run-sync": {
            "post": {
                "operationId": "run-sync-dtrungtin-fuzzy-search-dataset-actor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "datasetId",
                    "query"
                ],
                "properties": {
                    "datasetId": {
                        "title": "Dataset ID",
                        "type": "string",
                        "description": "The Apify dataset ID that contains the records you want to search. You can find this in the dataset URL or in Apify Console. Example: 'abc123DEF456'."
                    },
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "The text users want to search for. Fuzzy search allows typos and partial matches. Example: searching for 'iphon pro' can still match 'iPhone 15 Pro Max'."
                    },
                    "fields": {
                        "title": "Search Fields",
                        "type": "array",
                        "description": "List of dataset fields to search in. You can search multiple fields at the same time. Examples: 'title', 'description', 'brand', 'category', or nested fields like 'product.name'.",
                        "items": {
                            "type": "string"
                        },
                        "default": [
                            "title"
                        ]
                    },
                    "limit": {
                        "title": "Maximum Results",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum number of search results returned. Lower values improve performance. Recommended: 10 to 100.",
                        "default": 20
                    },
                    "threshold": {
                        "title": "Fuzzy Match Strictness",
                        "minimum": 0,
                        "maximum": 1,
                        "type": "number",
                        "description": "Controls how strict the fuzzy search is. Lower values require more accurate matches. Higher values allow more typos and loose matching. Recommended values: 0.2 = strict, 0.35 = balanced, 0.6 = very loose.",
                        "default": 0.35
                    },
                    "ignoreLocation": {
                        "title": "Ignore Word Position",
                        "type": "boolean",
                        "description": "When enabled, matches can appear anywhere inside the text. Example: searching 'pro' can match both 'iPhone Pro' and 'Professional Camera'. Recommended: enabled.",
                        "default": true
                    },
                    "minMatchCharLength": {
                        "title": "Minimum Match Length",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Minimum number of characters required before fuzzy considers a match. Helps reduce noisy results for very short queries. Recommended: 2 or 3.",
                        "default": 2
                    },
                    "includeScore": {
                        "title": "Include Relevance Score",
                        "type": "boolean",
                        "description": "Adds a relevance score to each result. Lower scores mean better matches. Useful for debugging, sorting, or displaying search confidence.",
                        "default": true
                    },
                    "includeMatches": {
                        "title": "Include Match Details",
                        "type": "boolean",
                        "description": "Returns detailed information about which text fragments matched the query. Useful for highlighting matched keywords in a frontend application.",
                        "default": false
                    },
                    "extendedSearch": {
                        "title": "Enable Advanced Search Syntax",
                        "type": "boolean",
                        "description": "Enables Fuzzy advanced query syntax. Examples: '^apple' = starts with apple, '!samsung' = exclude samsung, '=iphone' = exact match. Recommended for advanced users only.",
                        "default": false
                    },
                    "weights": {
                        "title": "Field Importance Weights",
                        "type": "object",
                        "description": "Optional JSON object that controls which fields are more important during ranking. Higher weight means higher priority in search results. Example: {\"title\": 0.7, \"description\": 0.2, \"brand\": 0.1}"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
