> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# insideBoundingBox

> Coordinates of rectangles in which to search

export const Setting = ({type, default: defaultValue, defaultNote, scope, min, max, formerly}) => {
  const renderedDefault = defaultValue === '' ? '""' : defaultValue;
  const renderedNote = defaultNote ? `(${defaultNote})` : '';
  return <ul>
      <li><strong>Type:</strong> <code>{type}</code></li>
      <li><strong>Default:</strong> <code>{renderedDefault}</code>{renderedNote}</li>
      {min && <li><strong>Min:</strong> <code>{min}</code></li>}
      {max && <li><strong>Max:</strong> <code>{max}</code></li>}
      <li><strong>Scope:</strong> <a href="/doc/api-reference/api-parameters"><code>{scope}</code></a></li>
      {formerly && <li>
          <strong>Deprecated name:</strong> <code>{formerly}</code>
        </li>}
    </ul>;
};

<Setting type="list<number>" default="null" scope="search" />

The `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

* [`aroundLatLng`](/doc/api-reference/api-parameters/aroundLatLng) and [`aroundLatLngViaIP`](/doc/api-reference/api-parameters/aroundLatLngViaIP)
  will be ignored if used along with this parameter.

* Can't be combined with [`insidePolygon`](/doc/api-reference/api-parameters/insidePolygon).
  If both are present, only `insideBoundingBox` is applied.

* Be cautious when specifying rectangles that cross the [180th meridian](/doc/guides/managing-results/refine-results/geolocation/how-to/how-to-resolve-180-meridian-issue).

## Examples

### Search inside one rectangle

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen="true">
    <CodeGroup>
      ```cs C# theme={"system"}
      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 },
              }
            ),
          }
        )
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.searchSingleIndex(
        indexName: "INDEX_NAME",
        searchParams: SearchParamsObject(
          insideBoundingBox: [
            [
              49.067996905313834,
              65.73828125,
              25.905859247243498,
              128.8046875,
            ],
          ],
        ),
      );
      ```

      ```go Go theme={"system"}
      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)
      }
      ```

      ```java Java theme={"system"}
      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
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({
        indexName: 'indexName',
        searchParams: { insideBoundingBox: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]] },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams =
            SearchParamsObject(
              insideBoundingBox =
                InsideBoundingBox.of(
                  listOf(listOf(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875))
                )
            ),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->searchSingleIndex(
          'INDEX_NAME',
          ['insideBoundingBox' => [
              [
                  49.067996905313834,

                  65.73828125,

                  25.905859247243498,

                  128.8046875,
              ],
          ],
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "insideBoundingBox": [
                  [
                      49.067996905313834,
                      65.73828125,
                      25.905859247243498,
                      128.8046875,
                  ],
              ],
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index(
        "INDEX_NAME",
        Algolia::Search::SearchParamsObject.new(
          inside_bounding_box: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]]
        )
      )
      ```

      ```scala Scala theme={"system"}
      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")
      )
      ```

      ```swift Swift theme={"system"}
      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,
                      ]])))
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      index.Search(new Query("query")
      {
          InsideBoundingBox = new List>
          {
              new List
              {
                  46.650828100116044f,
                  7.123046875f,
                  45.17210966999772f,
                  1.009765625f
              }
          }
      });
      ```

      ```go Go theme={"system"}
      res, err := index.Search(
      	"query",
      	opt.InsideBoundingBox([][4]float64{
      		{
      			46.650828100116044, // p1Lat
      			7.123046875,        // p1Lng
      			45.17210966999772,  // p2Lat
      			1.009765625,        // p2Lng
      		},
      	}),
      )
      ```

      ```java Java theme={"system"}
      index.search(
          new Query("query")
              .setInsideBoundingBox(
                  Arrays.asList(
                      Arrays.asList(
                          46.650828100116044f, 7.123046875f, 45.17210966999772f, 1.009765625f))));
      ```

      ```js JavaScript theme={"system"}
      const boundingBox = [
        46.650828100116044, // p1Lat
        7.123046875, // p1Lng
        45.17210966999772, // p2Lat
        1.009765625, // p2Lng
      ];

      index
        .search("query", {
          insideBoundingBox: [boundingBox],
        })
        .then(({ hits }) => {
          console.log(hits);
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val query = query("query") {
          insideBoundingBox {
              +BoundingBox(
                  Point(46.650828100116044f, 7.123046875f),
                  Point(45.17210966999772f, 1.009765625f)
              )
          }
      }

      index.search(query)
      ```

      ```php PHP theme={"system"}
      $boundingBox = [
        46.650828100116044, // p1Lat
        7.123046875, // p1Lng
        45.17210966999772, // p2Lat
        1.009765625 // p2Lng
      ];

      $results = $index->search('query', [
        'insideBoundingBox' => [$boundingBox]
      ]);
      ```

      ```python Python theme={"system"}
      bounding_box = [
          46.650828100116044,  # p1Lat
          7.123046875,  # p1Lng
          45.17210966999772,  # p2Lat
          1.009765625,  # p2Lng
      ]

      results = index.search("query", {"insideBoundingBox": [bounding_box]})
      ```

      ```ruby Ruby theme={"system"}
      bounding_box = [
        # p1Lat
        46.650828100116044,
        # p1Lng
        7.123046875,
        # p2Lat
        45.17210966999772,
        # p2Lng
        1.009765625
      ]

      results = index.search(
        "query",
        {
          insideBoundingBox: [bounding_box]
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        search into "myIndex" query Query(
          query = Some("query"),
          insideBoundingBox = Some(Seq(
            InsideBoundingBox(
              46.650828100116044,
              7.123046875,
              45.17210966999772,
              1.009765625
            )
          ))
        )
      }
      ```

      ```swift Swift theme={"system"}
      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)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

### Search inside multiple rectangles

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen>
    <CodeGroup>
      ```cs C# theme={"system"}
      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 },
              }
            ),
          }
        )
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.searchSingleIndex(
        indexName: "INDEX_NAME",
        searchParams: SearchParamsObject(
          insideBoundingBox: [
            [
              49.067996905313834,
              65.73828125,
              25.905859247243498,
              128.8046875,
            ],
          ],
        ),
      );
      ```

      ```go Go theme={"system"}
      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)
      }
      ```

      ```java Java theme={"system"}
      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
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({
        indexName: 'indexName',
        searchParams: { insideBoundingBox: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]] },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams =
            SearchParamsObject(
              insideBoundingBox =
                InsideBoundingBox.of(
                  listOf(listOf(49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875))
                )
            ),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->searchSingleIndex(
          'INDEX_NAME',
          ['insideBoundingBox' => [
              [
                  49.067996905313834,

                  65.73828125,

                  25.905859247243498,

                  128.8046875,
              ],
          ],
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "insideBoundingBox": [
                  [
                      49.067996905313834,
                      65.73828125,
                      25.905859247243498,
                      128.8046875,
                  ],
              ],
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index(
        "INDEX_NAME",
        Algolia::Search::SearchParamsObject.new(
          inside_bounding_box: [[49.067996905313834, 65.73828125, 25.905859247243498, 128.8046875]]
        )
      )
      ```

      ```scala Scala theme={"system"}
      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")
      )
      ```

      ```swift Swift theme={"system"}
      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,
                      ]])))
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      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
              }
          }
      });
      ```

      ```go Go theme={"system"}
      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
      		},
      	}),
      )
      ```

      ```java Java theme={"system"}
      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))));
      ```

      ```js JavaScript theme={"system"}
      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);
        });
      ```

      ```kotlin Kotlin theme={"system"}
      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)
      ```

      ```php PHP theme={"system"}
      $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
        ]
      ]);
      ```

      ```python Python theme={"system"}
      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]})
      ```

      ```ruby Ruby theme={"system"}
      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
        ]
      })
      ```

      ```scala Scala theme={"system"}
      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)
          ))
        )
      }
      ```

      ```swift Swift theme={"system"}
      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)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
