What's new in v0.27
This month's release brings support for nested fields, typo tolerance customization, and new search parameters.
This article looks at some of the main and breaking changes, but you can view the full changelog here.
New feature: nested field support
Meilisearch now offers full support for nested document fields, allowing you to use dot notation to access these fields.
Let's take an example. If you have a book store index, you might want to make search results filterable by an author's surname but not by their given name:
curl -X POST 'http://localhost:7700/indexes/books/settings/filterable-attributes' -H 'Content-Type: application/json' --data-binary '[ "author.surname" ]'
You may use dot notation to access object properties anywhere in Meilisearch where you would use an attribute. For instance, you can access index settings like sortable attributes and searchable attributes or search parameters like attributesToHighlight
.
New feature: customize typo tolerance
Meilisearch is typo tolerant! This means our engine can interpret your search even if it contains typos or misspellings. With v0.27, you can customize the typo tolerance settings for an index using the new update typo tolerance endpoint or the existing update settings endpoint:
The new API endpoints for typo tolerance accept a typoTolerance
object with the following properties:
enabled
: whether the typo tolerance feature is enabled. Defaults to truedisableOnAttributes
: disables typo tolerance on specific document attributes. Typo tolerance is enabled on all attributes by default.disableOnWords
: disables typo tolerance on a set of query terms given during search. Typo tolerance does not ignore any words by default.minWordSizeForTypos
: Meilisearch only accepts typos in words over a certain sizeoneTypo
: Customize the minimum word size for accepting one typo. Defaults to 5 characters.twoTypos
: Customize the minimum word size for accepting two typos. Defaults to 9 characters.
Suppose you have a movie
index that contains many character names. You might want Meilisearch to never look for typos in certain words but be more permissive with everything else:
curl --location --request POST 'http://localhost:7700/indexes/children-movies/settings/typo-tolerance' --header 'Authorization: Bearer <API_KEY>' --header 'Content-Type: application/json' --data-raw '{ "enabled": true, "minWordLengthForTypo": { "oneTypo": 3, "twoTypos": 7 }, "disableOnWords": ["Shrek"], "disableOnAttributes": [] }'
You can read more on typo tolerance here.
New feature: improved highlighting and cropping search parameters
This release brings three new search parameters: highlightPreTag
, highlightPostTag
, and cropMarker
. The first two allow you to customize the appearance of highlighted search terms further, while the last one should be used in conjunction with attributesToCrop
.
When using attributesToHighlight
, Meilisearch encloses matching terms in <em>
and strings by default. You can now configure these values to include any string using the highlightPreTag
, and highlightPostTag
. As the name indicates, highlightPreTag
specifies the tag before the highlighted query terms, and highlightPostTag
after the highlighted query terms.
Likewise, when using attributesToCrop
, you can now change the default "…"
cropMarker
to any string for marking crop boundaries.
When designing an application that allows users to search through a database of movies, you might want to change cropMarker
and the highlight tags to match your design:
curl --location --request POST '<http://localhost:7700/indexes/movies/search>' \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data-raw '{ "q":"shifu", "attributesToCrop":["overview"], "attributesToHighlight":["overview"], "cropLength":10, "highlightPreTag":"<span class=’highlight’>", "highlightPostTag":"</span>", "cropMarker":"[…]" }'
Using the above query, the search term shifu
is enclosed within tags, and the cropped text is marked by […]
:
{ "id": "50393", "title": "Kung Fu Panda Holiday", "overview": "The Winter Feast is Po's favorite holiday. Every year he and his father hang decorations, cook together, and serve noodle soup to the villagers. But this year Shifu informs Po that as Dragon Warrior, it is his duty to host the formal Winter Feast at the Jade Palace. Po is caught between his obligations as the Dragon Warrior and his family traditions: between Shifu and Mr. Ping.", "_formatted": { "id": "50393", "title": "Kung Fu Panda Holiday", **"overview": "[…]the villagers. But this year <span class=’highlight’>Shifu</span> informs Po that as[…]"** } }
For more information, check out our guide on search parameters.
Breaking change: `cropLength` behavior
The cropLength
search parameter is now specified in the number of words instead of characters.
Let’s take an example query:
curl --location --request POST '<http://localhost:7700/indexes/movies/search>' \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data-raw '{ "q":"shifu", "attributesToCrop":["overview"], "cropLength":10 }'
Meilisearch v0.27 returns:
{ "id": "50393", "title": "Kung Fu Panda Holiday", "overview": "The Winter Feast is Po's favorite holiday. Every year he and his father hang decorations, cook together, and serve noodle soup to the villagers. But this year Shifu informs Po that as Dragon Warrior, it is his duty to host the formal Winter Feast at the Jade Palace. Po is caught between his obligations as the Dragon Warrior and his family traditions: between Shifu and Mr. Ping.", "_formatted": { "id": "50393", "title": "Kung Fu Panda Holiday", **"overview": "…the villagers. But this year Shifu informs Po that as…",** } }
Breaking change: improved Docker workflow
Docker now starts from a different working directory: /meili_data
. This streamlines situations when you might want to use snapshots and dumps with Docker.
Usage remains mostly the same, but don't forget to update the data path:
docker run -it --rm \ -p 7700:7700 \ -v $(pwd)/meili_data:/meili_data \ getmeili/meilisearch:latest
With this change, dumps and snapshot features should work with Docker right out of the box. Rather than mounting separate volumes, it mounts all Meilisearch data into the meili_data directory.
Another consequence of this change is that the meilisearch
binary has been moved to a new location. When using instance options to configure Meilisearch, you must now use meilisearch
, /meilisearch
, or /bin/meilisearch
instead of ./meilisearch. We recommend using meilisearch
, though.
The updated command is:
docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest **meilisearch** --master-key="foobar"
Other Changes
- A typo on the first letter of a word will count as two typos. This reduces the search space for typo tolerance resulting in a faster search response time
- Meilisearch now has a non-customizable limit of returning 1000 documents per search to protect the database from malicious scraping.
- We added two new instance options to allow you more control over the use of machine resources during indexation(--max-indexing-memory and —-max-indexing-threads).
- We now support Japanese.
- The speed of adding new documents to a non-empty index has improved.
Contributors
A big thank you to all our contributors! We wouldn't have made it here without your support. This month, we want to send a special shout-out to @miiton, @djKooks, @mosuka for adding Japanese support, @2shiori17 for adding support for new instance options for RAM and CPU usage during indexation.
And that's all, folks! Remember to check out the changelog for the full release notes, and see you next month!