insidePolygon parameter restricts search results to records located within one or more geographic polygons.
Each polygon is defined by a series of latitude/longitude points (lat1, lng1, lat2, lng2, …),
with at least 3 points (6 values).
You can specify:
- A single polygon as a flat list of numbers
- Multiple polygons as a list of such lists
Usage
- Minimum of 3 coordinate pairs (6 values) per polygon
- Up to 10,000 coordinate pairs supported per request
- If both
insidePolygonandinsideBoundingBoxare specified, onlyinsideBoundingBoxis applied aroundLatLngandaroundLatLngViaIPwill be ignored if used withinsidePolygon.- To match all records within the polygon, send an empty query (
"") - Avoid polygons that cross the 180th meridian
Examples
Search inside a single polygon
Current API clients
Current API clients
var response = await client.SearchSingleIndexAsync<Hit>(
"INDEX_NAME",
new SearchParams(
new SearchParamsObject
{
InsidePolygon = new List<List<Double>>
{
new List<Double>
{
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
},
},
}
)
);
final response = await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchParamsObject(
insidePolygon: [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
],
],
),
);
response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
"INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
search.NewEmptySearchParamsObject().SetInsidePolygon(
[][]float64{
{
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
},
}))))
if err != nil {
// handle the eventual error
panic(err)
}
SearchResponse response = client.searchSingleIndex(
"INDEX_NAME",
new SearchParamsObject().setInsidePolygon(
Arrays.asList(
Arrays.asList(
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125
)
)
),
Hit.class
);
const response = await client.searchSingleIndex({
indexName: 'indexName',
searchParams: {
insidePolygon: [
[
42.01, -124.31, 48.835509470063045, -124.40453125000005, 45.01082951668149, -65.95726562500005,
31.247243545293433, -81.06578125000004, 25.924152577235226, -97.68234374999997, 32.300311895879545,
-117.54828125,
],
],
},
});
var response =
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams =
SearchParamsObject(
insidePolygon =
listOf(
listOf(
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
)
)
),
)
$response = $client->searchSingleIndex(
'INDEX_NAME',
['insidePolygon' => [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
],
],
],
);
response = client.search_single_index(
index_name="INDEX_NAME",
search_params={
"insidePolygon": [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
],
],
},
)
response = client.search_single_index(
"INDEX_NAME",
Algolia::Search::SearchParamsObject.new(
inside_polygon: [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125
]
]
)
)
val response = Await.result(
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(
SearchParamsObject(
insidePolygon = Some(
Seq(
Seq(42.01, -124.31, 48.835509470063045, -124.40453125000005, 45.01082951668149, -65.95726562500005,
31.247243545293433, -81.06578125000004, 25.924152577235226, -97.68234374999997, 32.300311895879545,
-117.54828125)
)
)
)
)
),
Duration(100, "sec")
)
let response: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(insidePolygon: [[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
]]))
)
Legacy API clients
Legacy API clients
index.Search(new Query("query")
{
InsidePolygon = new List>
{
new List
{
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f
}
}
});
res, err := index.Search(
"query",
opt.InsidePolygon([][]float64{
{
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625, // p3Lng
},
}),
)
index.search(
new Query("query")
.setInsidePolygon(
Arrays.asList(
Arrays.asList(
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f))));
const polygon = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625, // p3Lng
];
index
.search("query", {
insidePolygon: [polygon],
})
.then(({ hits }) => {
console.log(hits);
});
val query = query("query") {
insidePolygon {
+Polygon(
Point(latitude = 46.650828100116044f, longitude = 7.123046875f),
Point(latitude = 45.17210966999772f, longitude = 1.009765625f),
Point(latitude = 49.62625916704081f, longitude = 4.6181640625f)
)
}
}
index.search(query)
$polygon = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625 // p3Lng
];
$results = $index->search('query', [
'insidePolygon' => [$polygon]
]);
polygon = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
49.62625916704081, # p3Lat
4.6181640625, # p3Lng
]
results = index.search("query", {"insidePolygon": [polygon]})
polygon = [
# p1Lat
46.650828100116044,
# p1Lng
7.123046875,
# p2Lat
45.17210966999772,
# p2Lng
1.009765625,
# p3Lat
49.62625916704081,
# p3Lng
4.6181640625
]
results = index.search(
"query",
{
insidePolygon: [polygon]
}
)
client.execute {
search into "myIndex" query Query(
query = Some("query"),
insidePolygon = Some(Seq(
InsidePolygon(
46.650828100116044,
7.123046875,
45.17210966999772,
1.009765625,
49.62625916704081,
4.6181640625
)
))
)
}
let polygon = Polygon(
(46.650828100116044, 7.123046875),
(45.17210966999772, 1.009765625),
(49.62625916704081, 4.6181640625),
(47.715070300900194, 0.482421875)
)
let query = Query("query")
.set(\.insidePolygon, to: [polygon])
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Search inside multiple polygons
Current API clients
Current API clients
var response = await client.SearchSingleIndexAsync<Hit>(
"INDEX_NAME",
new SearchParams(
new SearchParamsObject
{
InsidePolygon = new List<List<Double>>
{
new List<Double>
{
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
},
},
}
)
);
final response = await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchParamsObject(
insidePolygon: [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
],
],
),
);
response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
"INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
search.NewEmptySearchParamsObject().SetInsidePolygon(
[][]float64{
{
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
},
}))))
if err != nil {
// handle the eventual error
panic(err)
}
SearchResponse response = client.searchSingleIndex(
"INDEX_NAME",
new SearchParamsObject().setInsidePolygon(
Arrays.asList(
Arrays.asList(
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125
)
)
),
Hit.class
);
const response = await client.searchSingleIndex({
indexName: 'indexName',
searchParams: {
insidePolygon: [
[
42.01, -124.31, 48.835509470063045, -124.40453125000005, 45.01082951668149, -65.95726562500005,
31.247243545293433, -81.06578125000004, 25.924152577235226, -97.68234374999997, 32.300311895879545,
-117.54828125,
],
],
},
});
var response =
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams =
SearchParamsObject(
insidePolygon =
listOf(
listOf(
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
)
)
),
)
$response = $client->searchSingleIndex(
'INDEX_NAME',
['insidePolygon' => [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
],
],
],
);
response = client.search_single_index(
index_name="INDEX_NAME",
search_params={
"insidePolygon": [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
],
],
},
)
response = client.search_single_index(
"INDEX_NAME",
Algolia::Search::SearchParamsObject.new(
inside_polygon: [
[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125
]
]
)
)
val response = Await.result(
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(
SearchParamsObject(
insidePolygon = Some(
Seq(
Seq(42.01, -124.31, 48.835509470063045, -124.40453125000005, 45.01082951668149, -65.95726562500005,
31.247243545293433, -81.06578125000004, 25.924152577235226, -97.68234374999997, 32.300311895879545,
-117.54828125)
)
)
)
)
),
Duration(100, "sec")
)
let response: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(insidePolygon: [[
42.01,
-124.31,
48.835509470063045,
-124.40453125000005,
45.01082951668149,
-65.95726562500005,
31.247243545293433,
-81.06578125000004,
25.924152577235226,
-97.68234374999997,
32.300311895879545,
-117.54828125,
]]))
)
Legacy API clients
Legacy API clients
index.Search(new Query("query")
{
InsidePolygon = new List>
{
new List
{
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f
}
}
});
res, err := index.Search(
"query",
opt.InsidePolygon([][]float64{
{
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625, // p3Lng
},
}),
)
index.search(
new Query("query")
.setInsidePolygon(
Arrays.asList(
Arrays.asList(
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f))));
const polygon = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625, // p3Lng
];
index
.search("query", {
insidePolygon: [polygon],
})
.then(({ hits }) => {
console.log(hits);
});
val query = query("query") {
insidePolygon {
+Polygon(
Point(latitude = 46.650828100116044f, longitude = 7.123046875f),
Point(latitude = 45.17210966999772f, longitude = 1.009765625f),
Point(latitude = 49.62625916704081f, longitude = 4.6181640625f)
)
}
}
index.search(query)
$polygon = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625 // p3Lng
];
$results = $index->search('query', [
'insidePolygon' => [$polygon]
]);
polygon = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
49.62625916704081, # p3Lat
4.6181640625, # p3Lng
]
results = index.search("query", {"insidePolygon": [polygon]})
polygon = [
# p1Lat
46.650828100116044,
# p1Lng
7.123046875,
# p2Lat
45.17210966999772,
# p2Lng
1.009765625,
# p3Lat
49.62625916704081,
# p3Lng
4.6181640625
]
results = index.search(
"query",
{
insidePolygon: [polygon]
}
)
client.execute {
search into "myIndex" query Query(
query = Some("query"),
insidePolygon = Some(Seq(
InsidePolygon(
46.650828100116044,
7.123046875,
45.17210966999772,
1.009765625,
49.62625916704081,
4.6181640625
)
))
)
}
let polygon = Polygon(
(46.650828100116044, 7.123046875),
(45.17210966999772, 1.009765625),
(49.62625916704081, 4.6181640625),
(47.715070300900194, 0.482421875)
)
let query = Query("query")
.set(\.insidePolygon, to: [polygon])
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Search inside multiple polygons
Current API clients
Current API clients
index.Search(new Query("query")
{
InsidePolygon = new List>
{
new List
{
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f
},
new List
{
49.62625916704081f,
4.6181640625f,
47.715070300900194f,
0.482421875f,
45.17210966999772f,
1.009765625f,
50.62626704081f,
4.6181640625f
}
}
});
res, err := index.Search(
"query",
opt.InsidePolygon([][]float64{
{
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625, // p3Lng
},
{
49.62625916704081, // p1Lat
4.6181640625, // p1Lng
47.715070300900194, // p2Lat
0.482421875, // p2Lng
45.17210966999772, // p3Lat
1.009765625, // p3Lng
50.62626704081, // p4Lat
4.6181640625, // p4Lng
},
}),
)
index.search(
new Query("query")
.setInsidePolygon(
Arrays.asList(
Arrays.asList(
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f),
Arrays.asList(
49.62625916704081f,
4.6181640625f,
47.715070300900194f,
0.482421875f,
45.17210966999772f,
1.009765625f,
50.62626704081f,
4.6181640625f))));
const polygon1 = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625 // p3Lng
];
const polygon2 = [
49.62625916704081, // p1Lat
4.6181640625 // p1Lng
47.715070300900194 // p2Lat
0.482421875 // p2Lng
45.17210966999772, // p3Lat
1.009765625, // p3Lng
50.62626704081, // p4Lat
4.6181640625 // p4Lng
];
index.search('query', {
insidePolygon: [polygon1, polygon2]
}).then(({ hits }) => {
console.log(hits);
});
val query = query("query") {
insidePolygon {
+Polygon(
Point(latitude = 46.650828100116044f, longitude = 7.123046875f),
Point(latitude = 45.17210966999772f, longitude = 1.009765625f),
Point(latitude = 49.62625916704081f, longitude = 4.6181640625f)
)
+Polygon(
Point(latitude = 49.62625916704081f, longitude = 4.6181640625f),
Point(latitude = 47.715070300900194f, longitude = 0.482421875f),
Point(latitude = 45.17210966999772f, longitude = 1.009765625f),
Point(latitude = 50.62626704081f, longitude = 4.6181640625f)
)
}
}
index.search(query)
$polygon1 = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625 // p3Lng
];
$polygon2 = [
49.62625916704081, // p1Lat
4.6181640625 // p1Lng
47.715070300900194 // p2Lat
0.482421875 // p2Lng
45.17210966999772, // p3Lat
1.009765625, // p3Lng
50.62626704081, // p4Lat
4.6181640625 // p4Lng
];
$results = $index->search('query', [
'insidePolygon' => [
$polygon1,
$polygon2
]
]);
polygon1 = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
49.62625916704081, # p3Lat
4.6181640625, # p3Lng
]
polygon2 = [
49.62625916704081, # p1Lat
4.6181640625, # p1Lng
47.715070300900194, # p2Lat
0.482421875, # p2Lng
45.17210966999772, # p3Lat
1.009765625, # p3Lng
50.62626704081, # p4Lat
4.6181640625, # p4Lng
]
results = index.search("query", {"insidePolygon": [polygon1, polygon2]})
polygon1 = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
49.62625916704081, # p3Lat
4.6181640625 # p3Lng
]
polygon2 = [
49.62625916704081, # p1_lat
4.6181640625 # p1Lng
47.715070300900194 # p2Lat
0.482421875 # p2Lng
45.17210966999772, # p3Lat
1.009765625, # p3Lng
50.62626704081, # p4Lat
4.6181640625 # p4Lng
]
results = index.search('query', {
insidePolygon: [polygon1, polygon2]
})
client.execute {
search into "myIndex" query Query(
query = Some("query"),
insidePolygon = Some(Seq(
InsidePolygon(
46.650828100116044,
7.123046875,
45.17210966999772,
1.009765625,
49.62625916704081,
4.6181640625
),
InsidePolygon(
49.62625916704081,
4.6181640625,
47.715070300900194,
0.482421875,
45.17210966999772,
1.009765625,
50.62626704081,
4.6181640625
)
))
)
}
let polygon1 = Polygon(
(46.650828100116044, 7.123046875),
(45.17210966999772, 1.009765625),
(49.62625916704081, 4.6181640625),
(47.715070300900194, 0.482421875)
)
let polygon2 = Polygon(
(47.650828100116044, 6.123046875),
(46.17210966999772, 1.009765625),
(48.62625916704081, 3.6181640625),
(45.715070300900194, 0.482421875)
)
let query = Query("query")
.set(\.insidePolygon, to: [
polygon1,
polygon2
])
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Legacy API clients
Legacy API clients
index.Search(new Query("query")
{
InsidePolygon = new List>
{
new List
{
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f
},
new List
{
49.62625916704081f,
4.6181640625f,
47.715070300900194f,
0.482421875f,
45.17210966999772f,
1.009765625f,
50.62626704081f,
4.6181640625f
}
}
});
res, err := index.Search(
"query",
opt.InsidePolygon([][]float64{
{
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625, // p3Lng
},
{
49.62625916704081, // p1Lat
4.6181640625, // p1Lng
47.715070300900194, // p2Lat
0.482421875, // p2Lng
45.17210966999772, // p3Lat
1.009765625, // p3Lng
50.62626704081, // p4Lat
4.6181640625, // p4Lng
},
}),
)
index.search(
new Query("query")
.setInsidePolygon(
Arrays.asList(
Arrays.asList(
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f,
49.62625916704081f,
4.6181640625f),
Arrays.asList(
49.62625916704081f,
4.6181640625f,
47.715070300900194f,
0.482421875f,
45.17210966999772f,
1.009765625f,
50.62626704081f,
4.6181640625f))));
const polygon1 = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625 // p3Lng
];
const polygon2 = [
49.62625916704081, // p1Lat
4.6181640625 // p1Lng
47.715070300900194 // p2Lat
0.482421875 // p2Lng
45.17210966999772, // p3Lat
1.009765625, // p3Lng
50.62626704081, // p4Lat
4.6181640625 // p4Lng
];
index.search('query', {
insidePolygon: [polygon1, polygon2]
}).then(({ hits }) => {
console.log(hits);
});
val query = query("query") {
insidePolygon {
+Polygon(
Point(latitude = 46.650828100116044f, longitude = 7.123046875f),
Point(latitude = 45.17210966999772f, longitude = 1.009765625f),
Point(latitude = 49.62625916704081f, longitude = 4.6181640625f)
)
+Polygon(
Point(latitude = 49.62625916704081f, longitude = 4.6181640625f),
Point(latitude = 47.715070300900194f, longitude = 0.482421875f),
Point(latitude = 45.17210966999772f, longitude = 1.009765625f),
Point(latitude = 50.62626704081f, longitude = 4.6181640625f)
)
}
}
index.search(query)
$polygon1 = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
49.62625916704081, // p3Lat
4.6181640625 // p3Lng
];
$polygon2 = [
49.62625916704081, // p1Lat
4.6181640625 // p1Lng
47.715070300900194 // p2Lat
0.482421875 // p2Lng
45.17210966999772, // p3Lat
1.009765625, // p3Lng
50.62626704081, // p4Lat
4.6181640625 // p4Lng
];
$results = $index->search('query', [
'insidePolygon' => [
$polygon1,
$polygon2
]
]);
polygon1 = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
49.62625916704081, # p3Lat
4.6181640625, # p3Lng
]
polygon2 = [
49.62625916704081, # p1Lat
4.6181640625, # p1Lng
47.715070300900194, # p2Lat
0.482421875, # p2Lng
45.17210966999772, # p3Lat
1.009765625, # p3Lng
50.62626704081, # p4Lat
4.6181640625, # p4Lng
]
results = index.search("query", {"insidePolygon": [polygon1, polygon2]})
polygon1 = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
49.62625916704081, # p3Lat
4.6181640625 # p3Lng
]
polygon2 = [
49.62625916704081, # p1_lat
4.6181640625 # p1Lng
47.715070300900194 # p2Lat
0.482421875 # p2Lng
45.17210966999772, # p3Lat
1.009765625, # p3Lng
50.62626704081, # p4Lat
4.6181640625 # p4Lng
]
results = index.search('query', {
insidePolygon: [polygon1, polygon2]
})
client.execute {
search into "myIndex" query Query(
query = Some("query"),
insidePolygon = Some(Seq(
InsidePolygon(
46.650828100116044,
7.123046875,
45.17210966999772,
1.009765625,
49.62625916704081,
4.6181640625
),
InsidePolygon(
49.62625916704081,
4.6181640625,
47.715070300900194,
0.482421875,
45.17210966999772,
1.009765625,
50.62626704081,
4.6181640625
)
))
)
}
let polygon1 = Polygon(
(46.650828100116044, 7.123046875),
(45.17210966999772, 1.009765625),
(49.62625916704081, 4.6181640625),
(47.715070300900194, 0.482421875)
)
let polygon2 = Polygon(
(47.650828100116044, 6.123046875),
(46.17210966999772, 1.009765625),
(48.62625916704081, 3.6181640625),
(45.715070300900194, 0.482421875)
)
let query = Query("query")
.set(\.insidePolygon, to: [
polygon1,
polygon2
])
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}