insideBoundingBox parameter defines rectangles in which to search.
Only records with coordinates (_geoloc attribute) within these rectangles are included in the search results.
Each rectangle is defined by the latitude and longitude of two diagonally opposite corners (p1Lat, p1Lng, p2Lat, p2Lng).
Usage
-
Use a list of 4 numbers for one rectangle.
For example:
[47.3165, 4.9665, 47.3424, 5.0201] -
Use multiple rectangles by:
-
Providing a longer flat list (must be multiples of 4: 8, 12, 16, … values).
For example:
47.3165,4.9665,47.3424,5.0201,40.9234,2.1185,38.6430,1.9916. -
Using a list of lists, each list with 4 values.
For example:
[[47.3165, 4.9665, 47.3424, 5.0201], [40.9234, 2.1185, 38.6430, 1.9916]]. - Records that are in either rectangle will be returned
-
Providing a longer flat list (must be multiples of 4: 8, 12, 16, … values).
For example:
-
aroundLatLngandaroundLatLngViaIPwill be ignored if used along with this parameter. -
Can’t be combined with
insidePolygon. If both are present, onlyinsideBoundingBoxis applied. - Be cautious when specifying rectangles that cross the 180th meridian.
Examples
Search inside one rectangle
Current API clients
Current API clients
var response = await client.SearchSingleIndexAsync<Hit>(
"INDEX_NAME",
new SearchParams(
new SearchParamsObject
{
InsideBoundingBox = new InsideBoundingBox(
new List<List<Double>>
{
new List<Double> { 49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875 },
}
),
}
)
);
final response = await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchParamsObject(
insideBoundingBox: [
[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
],
],
),
);
response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
"INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
search.NewEmptySearchParamsObject().SetInsideBoundingBox(search.ArrayOfArrayOfFloat64AsInsideBoundingBox(
[][]float64{
{49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875},
})))))
if err != nil {
// handle the eventual error
panic(err)
}
SearchResponse response = client.searchSingleIndex(
"INDEX_NAME",
new SearchParamsObject().setInsideBoundingBox(
InsideBoundingBox.of(Arrays.asList(Arrays.asList(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875)))
),
Hit.class
);
const response = await client.searchSingleIndex({
indexName: 'indexName',
searchParams: { insideBoundingBox: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]] },
});
var response =
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams =
SearchParamsObject(
insideBoundingBox =
InsideBoundingBox.of(
listOf(listOf(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875))
)
),
)
$response = $client->searchSingleIndex(
'INDEX_NAME',
['insideBoundingBox' => [
[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
],
],
],
);
response = client.search_single_index(
index_name="INDEX_NAME",
search_params={
"insideBoundingBox": [
[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
],
],
},
)
response = client.search_single_index(
"INDEX_NAME",
Algolia::Search::SearchParamsObject.new(
inside_bounding_box: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]]
)
)
val response = Await.result(
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(
SearchParamsObject(
insideBoundingBox =
Some(InsideBoundingBox(Seq(Seq(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875))))
)
)
),
Duration(100, "sec")
)
let response: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams
.searchSearchParamsObject(SearchSearchParamsObject(insideBoundingBox: SearchInsideBoundingBox
.arrayOfArrayOfDouble([[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
]])))
)
Legacy API clients
Legacy API clients
index.Search(new Query("query")
{
InsideBoundingBox = new List>
{
new List
{
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f
}
}
});
res, err := index.Search(
"query",
opt.InsideBoundingBox([][4]float64{
{
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
},
}),
)
index.search(
new Query("query")
.setInsideBoundingBox(
Arrays.asList(
Arrays.asList(
46.650828100116044f, 7.123046875f, 45.17210966999772f, 1.009765625f))));
const boundingBox = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
];
index
.search("query", {
insideBoundingBox: [boundingBox],
})
.then(({ hits }) => {
console.log(hits);
});
val query = query("query") {
insideBoundingBox {
+BoundingBox(
Point(46.650828100116044f, 7.123046875f),
Point(45.17210966999772f, 1.009765625f)
)
}
}
index.search(query)
$boundingBox = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625 // p2Lng
];
$results = $index->search('query', [
'insideBoundingBox' => [$boundingBox]
]);
bounding_box = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
]
results = index.search("query", {"insideBoundingBox": [bounding_box]})
bounding_box = [
# p1Lat
46.650828100116044,
# p1Lng
7.123046875,
# p2Lat
45.17210966999772,
# p2Lng
1.009765625
]
results = index.search(
"query",
{
insideBoundingBox: [bounding_box]
}
)
client.execute {
search into "myIndex" query Query(
query = Some("query"),
insideBoundingBox = Some(Seq(
InsideBoundingBox(
46.650828100116044,
7.123046875,
45.17210966999772,
1.009765625
)
))
)
}
let query = Query("query")
.set(\.insideBoundingBox, to: [
BoundingBox(point1: (46.650828100116044, 7.123046875),
point2: (45.17210966999772, 1.009765625))
])
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Search inside multiple rectangles
Current API clients
Current API clients
var response = await client.SearchSingleIndexAsync<Hit>(
"INDEX_NAME",
new SearchParams(
new SearchParamsObject
{
InsideBoundingBox = new InsideBoundingBox(
new List<List<Double>>
{
new List<Double> { 49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875 },
}
),
}
)
);
final response = await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchParamsObject(
insideBoundingBox: [
[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
],
],
),
);
response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
"INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
search.NewEmptySearchParamsObject().SetInsideBoundingBox(search.ArrayOfArrayOfFloat64AsInsideBoundingBox(
[][]float64{
{49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875},
})))))
if err != nil {
// handle the eventual error
panic(err)
}
SearchResponse response = client.searchSingleIndex(
"INDEX_NAME",
new SearchParamsObject().setInsideBoundingBox(
InsideBoundingBox.of(Arrays.asList(Arrays.asList(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875)))
),
Hit.class
);
const response = await client.searchSingleIndex({
indexName: 'indexName',
searchParams: { insideBoundingBox: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]] },
});
var response =
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams =
SearchParamsObject(
insideBoundingBox =
InsideBoundingBox.of(
listOf(listOf(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875))
)
),
)
$response = $client->searchSingleIndex(
'INDEX_NAME',
['insideBoundingBox' => [
[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
],
],
],
);
response = client.search_single_index(
index_name="INDEX_NAME",
search_params={
"insideBoundingBox": [
[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
],
],
},
)
response = client.search_single_index(
"INDEX_NAME",
Algolia::Search::SearchParamsObject.new(
inside_bounding_box: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]]
)
)
val response = Await.result(
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(
SearchParamsObject(
insideBoundingBox =
Some(InsideBoundingBox(Seq(Seq(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875))))
)
)
),
Duration(100, "sec")
)
let response: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams
.searchSearchParamsObject(SearchSearchParamsObject(insideBoundingBox: SearchInsideBoundingBox
.arrayOfArrayOfDouble([[
49.067996905313834,
65.73828125,
25.905859247243498,
128.8046875,
]])))
)
Legacy API clients
Legacy API clients
index.Search(new Query("query")
{
InsideBoundingBox = new List>
{
new List
{
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f
},
new List
{
49.62625916704081f,
4.6181640625f,
47.715070300900194f,
0.482421875f
}
}
});
res, err := index.Search(
"query",
opt.InsideBoundingBox([][4]float64{
{
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
},
{
49.62625916704081, // p1Lat
4.6181640625, // p1Lng
47.715070300900194, // p2Lat
0.482421875, // p2Lng
},
}),
)
index.search(
new Query("query")
.setInsideBoundingBox(
Arrays.asList(
Arrays.asList(
46.650828100116044f,
7.123046875f,
45.17210966999772f,
1.009765625f),
Arrays.asList(
49.62625916704081f,
4.6181640625f,
47.715070300900194f,
0.482421875f))));
const bounding_box1 = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
];
const bounding_box2 = [
49.62625916704081, // p1Lat
4.6181640625, // p1Lng
47.715070300900194, // p2Lat
0.482421875, // p2Lng
];
index
.search("query", {
insideBoundingBox: [bounding_box1, bounding_box2],
})
.then(({ hits }) => {
console.log(hits);
});
val query = query("query") {
insideBoundingBox {
+BoundingBox(
Point(latitude = 46.650828100116044f, longitude = 7.123046875f),
Point(latitude = 45.17210966999772f, longitude = 1.009765625f)
)
+BoundingBox(
Point(latitude = 49.62625916704081f, longitude = 4.6181640625f),
Point(latitude = 47.715070300900194f, longitude = 0.482421875f)
)
}
}
index.search(query)
$boundingBox1 = [
46.650828100116044, // p1Lat
7.123046875, // p1Lng
45.17210966999772, // p2Lat
1.009765625, // p2Lng
];
$boundingBox2 = [
49.62625916704081, // p1Lat
4.6181640625 // p1Lng
47.715070300900194 // p2Lat
0.482421875 // p2Lng
];
$results = $index->search('query', [
'insideBoundingBox' => [
$boundingBox1,
$boundingBox2
]
]);
bounding_box1 = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
]
bounding_box2 = [
49.62625916704081, # p1Lat
4.6181640625, # p1Lng
47.715070300900194, # p2Lat
0.482421875, # p2Lng
]
results = index.search("query", {"insideBoundingBox": [bounding_box1, bounding_box2]})
bounding_box1 = [
46.650828100116044, # p1Lat
7.123046875, # p1Lng
45.17210966999772, # p2Lat
1.009765625, # p2Lng
]
bounding_box2 = [
49.62625916704081, # p1_lat
4.6181640625 # p1Lng
47.715070300900194 # p2Lat
0.482421875 # p2Lng
]
results = index.search('query', {
insideBoundingBox: [
bounding_box1,
bounding_box2
]
})
client.execute {
search into "myIndex" query Query(
query = Some("query"),
insideBoundingBox = Some(Seq(
InsideBoundingBox(46.650828100116044, 7.123046875, 45.17210966999772, 1.009765625),
InsideBoundingBox(49.62625916704081, 4.6181640625, 47.715070300900194, 0.482421875)
))
)
}
let boundingBox1 = BoundingBox(
point1: (46.650828100116044, 7.123046875),
point2: (45.17210966999772, 1.009765625)
)
let boundingBox2 = BoundingBox(
point1: (49.62625916704081, 4.6181640625),
point2: (47.715070300900194, 0.482421875)
)
let query = Query("query")
.set(\.insideBoundingBox, to: [boundingBox1, boundingBox2])
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}