Available modes
Prefix search allows Meilisearch to match documents based on the beginning of the last word in a query. For example, typing adv matches “adventure”, “adventure”, and “advanced”. This is the feature that powers the “search as you type” experience.
The prefixSearch index setting controls how Meilisearch handles prefix matching.
Available modes
| Mode | Description |
|---|---|
indexingTime |
Default. Prefix data structures are built during indexing. This enables fast prefix search at query time but increases index size and indexing duration. |
disabled |
Prefix search is turned off. Only exact word matches are returned. This reduces index size and speeds up indexing, but users must type complete words to find results. |
Check current prefix search setting
Retrieve the current prefixSearch setting for an index:
cURL
JS
Python
PHP
Ruby
Go
C#
Rust
curl \
-X GET 'MEILISEARCH_URL/indexes/INDEX_UID/settings/prefix-search' \
-H 'Authorization: Bearer API_KEY'
client.index('INDEX_NAME').getPrefixSearch();
client.index('books').get_prefix_search()
$client->index('INDEX_NAME')->getPrefixSearch();
client.index('INDEX_UID').prefix_search
client.Index("books").GetPrefixSearch()
await client.Index("books").GetPrefixSearchAsync();
let prefix_search: PrefixSearchSettings = client
.index(INDEX_UID)
.get_prefix_search()
.await
.unwrap();
By default, the response is “indexingTime”.
Disable prefix search
If your use case does not require search-as-you-type (for example, users submit complete queries via a search button), disabling prefix search can reduce index size and improve indexing performance:
cURL
JS
Python
PHP
Ruby
Go
C#
Rust
curl \
-X PUT 'MEILISEARCH_URL/indexes/INDEX_UID/settings/prefix-search' \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
--data-binary '"disabled"'
client.index('INDEX_NAME').updatePrefixSearch('disabled');
client.index('books').update_prefix_search(PrefixSearch.DISABLED)
$client->index('INDEX_NAME')->updatePrefixSearch('disabled');
client.index('INDEX_UID').update_prefix_search('disabled')
client.Index("books").UpdatePrefixSearch("disabled")
await client.Index("books").UpdatePrefixSearchAsync("disabled");
let task: TaskInfo = client
.index(INDEX_UID)
.set_prefix_search(PrefixSearchSettings::Disabled)
.await
.unwrap();
Updating the prefix search setting triggers a re-indexing of all documents in the index. This is an asynchronous operation. Use the task API to monitor progress.
Reset prefix search
Restore the default indexingTime behavior:
cURL
JS
Python
PHP
Ruby
Go
C#
Rust
curl \
-X DELETE 'MEILISEARCH_URL/indexes/INDEX_UID/settings/prefix-search' \
-H 'Authorization: Bearer API_KEY'
client.index('INDEX_NAME').resetPrefixSearch();
client.index('books').reset_prefix_search()
$client->index('INDEX_NAME')->resetPrefixSearch();
client.index('INDEX_UID').reset_prefix_search
client.Index("books").ResetPrefixSearch()
await client.Index("books").ResetPrefixSearchAsync();
let task: TaskInfo = client
.index(INDEX_UID)
.reset_prefix_search()
.await
.unwrap();
When to disable prefix search
- Form-based search: Users type a full query and press a search button rather than seeing results as they type
- Large datasets with performance constraints: Disabling prefix search reduces index size and speeds up both indexing and queries
- Exact matching requirements: When partial word matches would return too many irrelevant results
When to keep prefix search enabled
- Search-as-you-type interfaces: Users expect results to update instantly as they type each character
- Autocomplete experiences: Prefix matching is essential for suggesting completions
- Discovery-oriented search: Partial matches help users explore content they might not find with exact queries
Prefix search only applies to the last word in a multi-word query. Earlier words in the query must match completely (or within typo tolerance). For example, searching for harry pot matches “Harry Potter” because “harry” matches exactly and “pot” is a prefix match for “Potter”.
For the full API reference, see get prefix search.
