diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml
index c67b025e64..dea3daa918 100644
--- a/.code-samples.meilisearch.yaml
+++ b/.code-samples.meilisearch.yaml
@@ -362,6 +362,14 @@ filtering_guide_3: |-
"q": "Planet of the Apes",
"filter": "rating >= 3 AND (NOT director = \"Tim Burton\")"
}' \
+filtering_guide_nested_1: |-
+ curl \
+ -X POST 'http://localhost:7700/indexes/movies/search' \
+ -H 'Content-Type: application/json' \
+ --data-binary '{
+ "q": "thriller",
+ "filter": "rating.users >= 90"
+ }'
search_parameter_guide_query_1: |-
curl \
-X POST 'http://localhost:7700/indexes/movies/search' \
@@ -717,6 +725,14 @@ sorting_guide_update_ranking_rules_1: |-
"attribute",
"exactness"
]'
+sorting_guide_sort_nested_1: |-
+ curl \
+ -X POST 'http://localhost:7700/indexes/books/search' \
+ -H 'Content-Type: application/json' \
+ --data-binary '{
+ "q": "science fiction",
+ "sort": ["rating.users:asc"]
+ }'
sorting_guide_sort_parameter_1: |-
curl \
-X POST 'http://localhost:7700/indexes/books/search' \
diff --git a/.vuepress/public/sample-template.yaml b/.vuepress/public/sample-template.yaml
index 50ff3f3426..f6c0b4f9c2 100644
--- a/.vuepress/public/sample-template.yaml
+++ b/.vuepress/public/sample-template.yaml
@@ -59,6 +59,7 @@ field_properties_guide_displayed_1: |-
filtering_guide_1: |-
filtering_guide_2: |-
filtering_guide_3: |-
+filtering_guide_nested_1: |-
search_parameter_guide_query_1: |-
search_parameter_guide_offset_1: |-
search_parameter_guide_limit_1: |-
@@ -101,6 +102,7 @@ sorting_guide_update_sortable_attributes_1: |-
sorting_guide_update_ranking_rules_1: |-
sorting_guide_sort_parameter_1: |-
sorting_guide_sort_parameter_2: |-
+sorting_guide_sort_nested_1: |-
get_sortable_attributes_1: |-
update_sortable_attributes_1: |-
reset_sortable_attributes_1: |-
diff --git a/learn/advanced/filtering_and_faceted_search.md b/learn/advanced/filtering_and_faceted_search.md
index d11c7c0c14..b5784a94e6 100644
--- a/learn/advanced/filtering_and_faceted_search.md
+++ b/learn/advanced/filtering_and_faceted_search.md
@@ -35,6 +35,10 @@ Suppose you have a collection of movies containing the following fields:
"Horror",
"Mystery"
],
+ "rating": {
+ "critics": 86,
+ "users": 73
+ },
"overview": "Husband and wife Gabe and Adelaide Wilson take their…"
},
…
@@ -182,13 +186,16 @@ Suppose that you have a dataset containing several movies in the following forma
"Horror",
"Thriller"
],
- "rating": 4
+ "rating": {
+ "critics": 86,
+ "users": 73
+ },
},
…
]
```
-If you want to enable filtering using `director`, `release_date`, `genres`, and `rating`, you must add these attributes to the [`filterableAttributes` index setting](//reference/api/settings.md#filterable-attributes).
+If you want to enable filtering using `director`, `release_date`, `genres`, and `rating.users`, you must add these attributes to the [`filterableAttributes` index setting](//reference/api/settings.md#filterable-attributes).
You can then restrict a search so it only returns movies released after 18 March 1995 with the following filter containing a single condition:
@@ -217,7 +224,7 @@ Note that filtering on string values is case-insensitive.
If you only want well-rated movies that weren't directed by `Tim Burton`, you can use this filter:
```SQL
-rating >= 3 AND (NOT director = "Tim Burton")
+rating.users >= 80 AND (NOT director = "Tim Burton")
```
You can use this filter when searching for `Planet of the Apes`:
@@ -227,7 +234,7 @@ You can use this filter when searching for `Planet of the Apes`:
`NOT director = "Tim Burton"` will include both documents that do not contain `"Tim Burton"` in its `director` field and documents without a `director` field. To return only documents that have a `director` field, expand the filter expression with the `EXISTS` operator:
```SQL
-rating >= 3 AND (NOT director = "Tim Burton" AND director EXISTS)
+rating.users >= 80 AND (NOT director = "Tim Burton" AND director EXISTS)
```
## Filtering with `_geoRadius`
@@ -250,6 +257,12 @@ When using a dataset of restaurants containing geopositioning data, we can filte
[You can read more about filtering results with `_geoRadius` in our geosearch guide.](/learn/advanced/geosearch.md#filtering-results-with-georadius)
+#### Filtering by nested fields
+
+Use dot notation to filter results based on a document's nested fields. The following query only returns thrillers with good user reviews:
+
+
+
## Faceted search
Meilisearch filters can be used to build **faceted search** interfaces. This type of interface allows users to refine search results based on broad categories or **facets**. For example, a clothing webshop can use faceted search to allow users to easily explore items of a certain size or belonging to a specific brand.
diff --git a/learn/advanced/sorting.md b/learn/advanced/sorting.md
index 5496d0b2ac..6dbf33e2e8 100644
--- a/learn/advanced/sorting.md
+++ b/learn/advanced/sorting.md
@@ -45,6 +45,10 @@ Suppose you have collection of books containing the following fields:
"genres": [
"science fiction"
],
+ "rating": {
+ "critics": 95,
+ "users": 87
+ },
"price": 5.00
},
{
@@ -54,6 +58,10 @@ Suppose you have collection of books containing the following fields:
"genres": [
"science fiction"
],
+ "rating": {
+ "critics": 90,
+ "users": 92
+ },
"price": 10.00
},
{
@@ -64,6 +72,10 @@ Suppose you have collection of books containing the following fields:
"feminism",
"philosophy"
],
+ "rating": {
+ "critics": 86,
+ "users": 73
+ },
"price": 10.00
},
{
@@ -73,6 +85,10 @@ Suppose you have collection of books containing the following fields:
"genres": [
"fantasy"
],
+ "rating": {
+ "critics": 84,
+ "users": 80
+ },
"price": 5.00
},
…
@@ -156,6 +172,10 @@ With our example dataset, the results look like this:
"genres": [
"science fiction"
],
+ "rating": {
+ "critics": 95,
+ "users": 87
+ },
"price": 5.00
},
{
@@ -165,6 +185,10 @@ With our example dataset, the results look like this:
"genres": [
"science fiction"
],
+ "rating": {
+ "critics": 90,
+ "users": 92
+ },
"price": 10.00
}
]
@@ -183,6 +207,10 @@ It is common to search books based on an author's name. `sort` can help grouping
"genres": [
"science fiction"
],
+ "rating": {
+ "critics": 90,
+ "users": 92
+ },
"price": 10.00
},
{
@@ -192,6 +220,10 @@ It is common to search books based on an author's name. `sort` can help grouping
"genres": [
"fantasy"
],
+ "rating": {
+ "critics": 84,
+ "users": 80
+ },
"price": 5.00
},
{
@@ -202,11 +234,21 @@ It is common to search books based on an author's name. `sort` can help grouping
"feminism",
"philosophy"
],
+ "rating": {
+ "critics": 86,
+ "users": 73
+ },
"price": 10.00
}
]
```
+#### Sorting by nested fields
+
+Use dot notation to sort results based on a document's nested fields. The following query sorts returned documents by their user review scores:
+
+
+
## Sorting and custom ranking rules
There is a lot of overlap between sorting and configuring [custom ranking rules](/learn/core_concepts/relevancy.md#custom-rules), as both can greatly influence which results a user will see first.
diff --git a/reference/api/search.md b/reference/api/search.md
index 6507e6c4b6..92bed763f0 100644
--- a/reference/api/search.md
+++ b/reference/api/search.md
@@ -439,7 +439,7 @@ You can then use the filter in a search query:
-#### Filtering results `_geoRadius`
+#### Filtering results with `_geoRadius`
If your documents contain `_geo` data, you can use the `_geoRadius` built-in filter rule to filter results according to their geographic position.