> ## Documentation Index
> Fetch the complete documentation index at: https://vlyai-1c28d863.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Full-text search

> BM25-style search across text fields. Built into Convex, no external service.

For text search (titles, descriptions, comments) where keyword match matters more than semantic similarity, use Convex's full-text search.

## Setup

### 1. Add a search index

```typescript convex/schema.ts theme={null}
tasks: defineTable({
  title:    v.string(),
  body:     v.string(),
  teamId:   v.id("teams"),
  status:   v.union(v.literal("open"), v.literal("done")),
})
  .searchIndex("search_text", {
    searchField:  "title",
    filterFields: ["teamId", "status"],
  })
```

### 2. Query

```typescript convex/tasks.ts theme={null}
export const search = query({
  args: { query: v.string(), teamId: v.id("teams") },
  handler: async (ctx, { query, teamId }) => {
    return await ctx.db
      .query("tasks")
      .withSearchIndex("search_text", q =>
        q.search("title", query).eq("teamId", teamId)
      )
      .take(20);
  },
});
```

## How it ranks

Convex uses a BM25-derived scoring algorithm — more matches in the search field rank higher; rarer words get more weight than common ones.

For semantic similarity (find similar items, not just keyword matches), use [vector search](/convex/vector-search).

## Limits

* One search field per index. To search both `title` and `body`, either index a concatenated field or maintain two search indexes.
* Filter fields combined with search support up to 16 fields.

## Tips

<Tip>
  **Search a concatenated field for "search across multiple columns."** Add a `searchableText` field that's `title + " " + body + " " + tags.join(" ")`, populate it on every write.
</Tip>

<Tip>
  **For autocomplete UIs, debounce the client.** A keystroke-by-keystroke search is wasteful; 200ms debounce is plenty.
</Tip>

## Related

<CardGroup cols={3}>
  <Card title="Vector search" icon="brain" href="/convex/vector-search">
    Semantic alternative.
  </Card>

  <Card title="Algolia" icon="search" href="/integrations/algolia">
    Hosted search with more features.
  </Card>

  <Card title="Schema" icon="database" href="/convex/schema">
    Search index syntax.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.