Skip to content

Commit 8672d57

Browse files
committed
Update README
1 parent 1e84be5 commit 8672d57

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/instant-meilisearch/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ The following parameters exist:
791791
- `boundingBox`: The Google Map window box. It is used as parameter in a search request. It takes precedent on all the following parameters.
792792
- `aroundLatLng`: The middle point of the Google Map. If `insideBoundingBox` or `boundingBox` is present, it is ignored.
793793
- `aroundRadius`: The radius around a Geo Point, used for sorting in the search request. It only works if `aroundLatLng` is present as well. If `insideBoundingBox` or `boundingBox` is present, it is ignored.
794+
- `insidePolygon`: Filters search results to only include documents whose coordinates fall within a specified polygon. This parameter accepts an array of coordinate pairs `[[lat, lng], [lat, lng], ...]` that define the polygon vertices (minimum 3 points required). When `insidePolygon` is specified, it takes precedence over `insideBoundingBox` and `around*` parameters. **Note**: This feature requires `_geojson` to be added to your Meilisearch index's `filterableAttributes` setting.
794795

795796

796797
For exemple, by adding `boundingBox` in the [`instantSearch`](#-instantsearch) widget parameters, the parameter will be used as a search parameter for the first request.
@@ -817,6 +818,26 @@ Alternatively, the parameters can be passed through the [`searchFunction`](https
817818
},
818819
```
819820

821+
You can also filter results within a polygon using `insidePolygon` (requires `_geojson` in your Meilisearch `filterableAttributes`).
822+
823+
```js
824+
// First, ensure your Meilisearch index has the correct settings:
825+
// {
826+
// "filterableAttributes": ["_geojson"]
827+
// }
828+
829+
// Then use insidePolygon in your search configuration:
830+
search.addWidgets([
831+
instantsearch.widgets.configure({
832+
insidePolygon: [
833+
[50.8466, 4.35],
834+
[50.75, 4.1],
835+
[50.65, 4.5],
836+
],
837+
}),
838+
])
839+
```
840+
820841
[Read the guide on how GeoSearch works in Meilisearch](https://www.meilisearch.com/docs/learn/getting_started/filtering_and_sorting#geosearch).
821842

822843
### ❌ Answers

0 commit comments

Comments
 (0)