Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit de32a1b

Browse files
committed
add descending order capability for _geoPoint built-in sort (#77)
1 parent acf6ceb commit de32a1b

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

text/0059-geo-search.md

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The purpose of this specification is to add a first iteration of the **geosearch
1515

1616
- Documents MUST have a `_geo` reserved object to be geosearchable.
1717
- Filter documents by a given geo radius using the built-in filter `_geoRadius({lat}, {lng}, {distance_in_meters})`. It is possible to cumulate several geosearch filters within the `filter` field.
18-
- Sort documents in ascending order around a geo point. e.g. `_geoPoint({lat}, {lng}):asc`. Descending order will not be supported for this first iteration.
18+
- Sort documents in ascending/descending order around a geo point. e.g. `_geoPoint({lat}, {lng}):asc`.
1919
- It is possible to filter and/or sort by geographical criteria of the user's choice.
2020
- `_geo` must be set as a filterable attribute to use geo filtering capabilities.
2121
- `_geo` must be set as a sortable attribute to use geo sort capabilities.
@@ -189,9 +189,7 @@ Following the [`sort` specification feature](https://github.com/meilisearch/spec
189189
>
190190
>There is no `geo` ranking rule as such. It is in fact within the `sort` ranking rule in an obfuscated way.
191191
>
192-
>`_geoPoint` built-in sort rule can sort documents in ascending order only.
193-
>
194-
> The `:desc` order is not supported due to a technical limit. See Technical Aspects part for more details.
192+
>`_geoPoint` built-in sort rule can sort documents in ascending/descending order.
195193
196194
#### GET Search `/indexes/{indexUid}/search`
197195

@@ -207,7 +205,6 @@ Following the [`sort` specification feature](https://github.com/meilisearch/spec
207205
}
208206
```
209207
- 🔴 Specifying parameters that do not conform to the `_geoPoint` signature causes the API to return an `invalid_sort` error. The error message should indicate how `_geoPoint` should be used. See `_geoPoint` built-in sort rule definition part.
210-
- 🔴 Specifying `:desc` for a `_geoPoint` sort rule will raise an `invalid_sort` error with a message explaining that `_geoPoint` can only be used with `:asc` order.
211208
- 🔴 Using `_geo`, `_geoDistance`, `_geoRadius` in a sort expression cause the API to return an `invalid_sort` error. `message` should be `:reservedKeyword is a reserved keyword and thus can't be used as a sort expression.`
212209

213210
---
@@ -260,39 +257,14 @@ This error is raised asynchronously when the user tries to specify an invalid ra
260257

261258
## 2. Technical Aspects
262259

263-
### I. :desc case - Sorting documents around a geo point
264-
265-
We may encounter technical difficulties to implement a descending order capability for the geo sorting. This first iteration will allow us to identify if this is a real technical problem. If we verify the existence of this problem, we will think at this moment of the best solution to bring on the table.
266-
267-
> 💡 In a first step, we could not allow `:desc` on a geoPoint if it's a complex technical issue.
268-
269-
---
270-
271-
Edit-date: 2021-08-31
272-
273-
As imagined during the first phases of discovery we encounter a technical difficulty to compute a descending order around a `_geoPoint`.
274-
275-
The technical team will have to do some preparatory work to overcome this limitation. For the time being, it is not planned to spend more time on this as it is not a primary use case. The impact may be very small, so it's not worth the effort at this point.
276-
277-
### Decision taken
278-
279-
It was decided after a discussion with @irevoire and @Kerollmops that when the user specifies the sort rule `_geoPoint(lat, lng):desc` an error `invalid_sort` will be returned with a message explaining that `:desc` is not available.
280-
281-
#### Why keep the :asc if :desc is not valid?
282-
283-
To keep consistency and not to introduce a different syntax among the `sort` search parameter. This is something we'll re-evaluate later.
284-
285-
---
286-
287-
### II. Measuring
260+
### I. Measuring
288261

289262
- `filterableAttribute` setting definition to evaluate `_geo` presence.
290263
- `sortableAttribute` setting definition to evaluate `_geo` presence.
291264

292265
## 3. Future Possibilities
293266

294267
- Add built-in filter to filter documents within `polygon` and `bounding-box`.
295-
- Handling `:desc` order around a geoPoint
296268
- Handling array of geo points in the document object.
297269
- Handling multiple geo formats for the `_geo` field. e.g. "{lat},{lng}", a geohash etc.
298270
- Handling distance in other formats (like the imperial format). **It's easy to implement on the user side though.**

0 commit comments

Comments
 (0)