Skip to content

Commit d0db786

Browse files
guimachiavelligmourierdichotommy
authored
Add phrase search (#1021)
* Add mentions of phrase search to learn/what_is_meilisearch/featuresd, reference/api/search, and reference/features/search_parameters * Update learn/what_is_meilisearch/features.md Co-authored-by: Guillaume Mourier <[email protected]> * Update reference/features/search_parameters: mention hard separators; link to document outlining both soft and hard separators Update reference/under_the_hood/contact: prefer "phrase search" over "phrase query" and link to the new phrase search heading * Update reference/features/search_parameters: add code sample * Update learn/what_is_meilisearch/features.md Co-authored-by: Tommy <[email protected]> * Update reference/features/search_parameters.md Co-authored-by: Tommy <[email protected]> * Update reference/features/search_parameters.md Co-authored-by: Tommy <[email protected]> * Update learn/what_is_meilisearch/features.md * Update reference/features/search_parameters.md Co-authored-by: Tommy <[email protected]> * Update reference/under_the_hood/concat.md Co-authored-by: Tommy <[email protected]> * Update reference/api/search: explicitly mention placeholder/phrase search on both POST and GET routes * Apply suggestions from code review Co-authored-by: Tommy <[email protected]> Co-authored-by: Guillaume Mourier <[email protected]> Co-authored-by: Tommy <[email protected]>
1 parent 1fd66a7 commit d0db786

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

learn/what_is_meilisearch/features.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ If you make a search without inputting any query words, MeiliSearch will return
4444

4545
Placeholder search is not affected by MeiliSearch's [default ranking rules](/reference/features/settings.md#ranking-rules)—only custom rules added by a user. If no custom rules have been set, the results are displayed in the order of their internal database position.
4646

47+
## Phrase search
48+
49+
If you enclose search terms in double quotes (`"`), MeiliSearch will only return documents that contain those terms in the order they were given. This gives users the option to make more precise search queries.
50+
51+
Phrase search is particularly useful when looking for a single result, such as searching for a book by ISBN. It is also possible to combine phrase searches with MeiliSearch's basic syntax so only parts of a query are matched strictly.
52+
4753
## Comprehensive language support
4854

4955
[MeiliSearch is multilingual](/reference/features/language.md)! We aim to support every language represented in our global community.

reference/api/search.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ This is the preferred route to perform search when an API key is required, as it
4141
4242
[Learn more about how to use the search parameters](/reference/features/search_parameters.md).
4343

44+
#### Placeholder search
45+
46+
When no search query is specified, a [placeholder search](/reference/features/search_parameters.md#query-q) is run instead.
47+
48+
#### Phrase search
49+
50+
Query terms enclosed in double quotes are treated as [phrase searches](/reference/features/search_parameters.md#query-q).
51+
4452
### Response
4553

4654
| field | Description | type |
@@ -131,7 +139,11 @@ This route should only be used when no API key is required. If an API key is req
131139

132140
#### Placeholder search
133141

134-
When the `q` parameter is not specified, a [placeholder](/reference/features/search_parameters.md#query-q) search is run instead.
142+
When no search query is specified, a [placeholder search](/reference/features/search_parameters.md#query-q) is run instead.
143+
144+
#### Phrase search
145+
146+
Query terms enclosed in double quotes are treated as [phrase searches](/reference/features/search_parameters.md#query-q).
135147

136148
### Response
137149

reference/features/search_parameters.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ This will give you a list of documents that contain your query terms in at least
7272
}
7373
```
7474

75+
### Phrase search
76+
77+
If you enclose search terms in double quotes (`"`), MeiliSearch will only return documents containing those terms in the order they were given. This is called a **phrase search**.
78+
79+
Phrase searches are case-insensitive and ignore [soft separators such as `-`, `,`, and `:`](/reference/under_the_hood/datatypes.md). Using a hard separator within a phrase search effectively splits it into multiple separate phrase searches: `"Octavia.Butler"` will return the same results as `"Octavia" "Butler"`.
80+
81+
You can combine phrase search and normal queries in a single search request. In this case, MeiliSearch will first fetch all documents with exact matches to the given phrase(s), and [then proceed with its default behavior](/learn/core_concepts/relevancy.md).
82+
83+
#### Example
84+
85+
<CodeSamples id="phrase_search_1" />
86+
7587
## Offset
7688

7789
**Parameter**: `offset`

reference/under_the_hood/concat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This consists of finding the most interesting place to separate the words and to
2626

2727
This is achieved by finding the best frequency of the separate words in the dictionary of all words in the dataset. It will look out that both words have a minimum of interesting results, and not just one of them.
2828

29-
Split words are not considered as multiple words in a search query because they must stay next to each other, this behavior is called **Phrase Queries**.
29+
Split words are not considered as multiple words in a search query because they must stay next to each other.
3030

3131
#### Example
3232

0 commit comments

Comments
 (0)