Skip to content

Commit ba24fb2

Browse files
committed
Update geosearch docs
1 parent 8672d57 commit ba24fb2

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

packages/instant-meilisearch/README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +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.
795-
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. Polygon filters require documents to contain a valid `_geojson` field with [GeoJSON format](https://geojson.org/). Documents without `_geojson` will not be returned in polygon searches, even if they have `_geo` coordinates.
796795

797796
For exemple, by adding `boundingBox` in the [`instantSearch`](#-instantsearch) widget parameters, the parameter will be used as a search parameter for the first request.
798797

@@ -818,15 +817,9 @@ Alternatively, the parameters can be passed through the [`searchFunction`](https
818817
},
819818
```
820819

821-
You can also filter results within a polygon using `insidePolygon` (requires `_geojson` in your Meilisearch `filterableAttributes`).
820+
You can also filter results within a polygon using `insidePolygon`.
822821

823822
```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:
830823
search.addWidgets([
831824
instantsearch.widgets.configure({
832825
insidePolygon: [
@@ -838,7 +831,7 @@ search.addWidgets([
838831
])
839832
```
840833

841-
[Read the guide on how GeoSearch works in Meilisearch](https://www.meilisearch.com/docs/learn/getting_started/filtering_and_sorting#geosearch).
834+
For more information, read the [geosearch documentation](https://www.meilisearch.com/docs/learn/filtering_and_sorting/geosearch).
842835

843836
### ❌ Answers
844837

playgrounds/geo-javascript/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h2>Search in world cities</h2>
3333

3434
<div class="right-panel">
3535
<div id="searchbox" class="ais-SearchBox"></div>
36-
<div id="maps" style="height: 500px; width: 500px"></div>
36+
<!-- <div id="maps" style="height: 500px; width: 500px"></div> -->
3737
<br />
3838
<div id="hits"></div>
3939
<div id="pagination"></div>

playgrounds/geo-javascript/src/app.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import { instantMeiliSearch } from '@meilisearch/instant-meilisearch'
33
import injectScript from 'scriptjs'
44

5-
const GOOGLE_API = process.env.GOOGLE_API
5+
const GOOGLE_API = import.meta.env.GOOGLE_API
66

77
injectScript(
88
`https://maps.googleapis.com/maps/api/js?v=quarterly&key=${GOOGLE_API}`,
99
() => {
1010
const search = instantsearch({
11-
indexName: 'world_cities',
11+
indexName: 'world_cities_geojson',
1212
searchClient: instantMeiliSearch(
13-
'https://ms-adf78ae33284-106.lon.meilisearch.io',
13+
'https://edge.meilisearch.com',
1414
'a63da4928426f12639e19d62886f621130f3fa9ff3c7534c5d179f0f51c4f303',
1515
{}
1616
).searchClient,
@@ -20,13 +20,13 @@ injectScript(
2020
instantsearch.widgets.sortBy({
2121
container: '#sort-by',
2222
items: [
23-
{ value: 'world_cities', label: 'Relevant' },
23+
{ value: 'world_cities_geojson', label: 'Relevant' },
2424
{
25-
value: 'world_cities:population:desc',
25+
value: 'world_cities_geojson:population:desc',
2626
label: 'Most Populated',
2727
},
2828
{
29-
value: 'world_cities:population:asc',
29+
value: 'world_cities_geojson:population:asc',
3030
label: 'Least Populated',
3131
},
3232
],
@@ -37,15 +37,15 @@ injectScript(
3737
instantsearch.widgets.configure({
3838
hitsPerPage: 20,
3939
}),
40-
instantsearch.widgets.geoSearch({
41-
container: '#maps',
42-
googleReference: window.google,
43-
initialZoom: 7,
44-
initialPosition: {
45-
lat: 50.655250871381355,
46-
lng: 4.843585698860502,
47-
},
48-
}),
40+
// instantsearch.widgets.geoSearch({
41+
// container: '#maps',
42+
// googleReference: window.google,
43+
// initialZoom: 7,
44+
// initialPosition: {
45+
// lat: 50.655250871381355,
46+
// lng: 4.843585698860502,
47+
// },
48+
// }),
4949
instantsearch.widgets.infiniteHits({
5050
container: '#hits',
5151
templates: {

0 commit comments

Comments
 (0)