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

# aroundPrecision

> Precision of location search in meters for grouping results with similar distance

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="integer | list<object>" default="10" scope="search" min="10" />

The `aroundPrecision` parameter controls how finely Algolia groups results by their distance from the search center.
This affects how the [Geo ranking criterion](/doc/guides/managing-results/refine-results/geolocation) treats nearby records.

## Usage

* The `geo` criterion must be in your ranking formula (default behavior).
* If you set a value below `10`, Algolia uses `10` as the minimum.
* Use an **integer** for a fixed grouping size in meters.
* Use a **list of range objects** to define custom precision ranges based on distance bands.

## Options

<ParamField path="integer">
  Groups results by distance in fixed increments.
  For example, `aroundPrecision: 100` means records from 0 to 99 m are ranked equally, as are 100 to 199 m, and so on.
</ParamField>

<ParamField path="list<object>">
  Provides variable precision at different distance ranges.
  Each object must include a `from` and a `value`.
  For example: `[{ "from": 0, "value": 25 }, { "from": 1000, "value": 2000 }]`
  means records between 0 and 999 m have a precision of 25 m,
  and records above 1,000 m have a precision of 2,000 m.
</ParamField>

## Examples

### Specify a number

<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 { Query = "query", AroundPrecision = new AroundPrecision(100) }
        )
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.searchSingleIndex(
        indexName: "INDEX_NAME",
        searchParams: SearchParamsObject(
          query: "query",
          aroundPrecision: 100,
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
        "INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
        search.NewEmptySearchParamsObject().SetQuery("query").SetAroundPrecision(search.Int32AsAroundPrecision(100)))))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      SearchResponse response = client.searchSingleIndex(
        "INDEX_NAME",
        new SearchParamsObject().setQuery("query").setAroundPrecision(AroundPrecision.of(100)),
        Hit.class
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({
        indexName: 'indexName',
        searchParams: { query: 'query', aroundPrecision: 100 },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams =
            SearchParamsObject(query = "query", aroundPrecision = AroundPrecision.of(100)),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->searchSingleIndex(
          'INDEX_NAME',
          ['query' => 'query',
              'aroundPrecision' => 100,
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "query": "query",
              "aroundPrecision": 100,
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index(
        "INDEX_NAME",
        Algolia::Search::SearchParamsObject.new(query: "query", around_precision: 100)
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = Some(
            SearchParamsObject(
              query = Some("query"),
              aroundPrecision = Some(AroundPrecision(100))
            )
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response: SearchResponse<Hit> = try await client.searchSingleIndex(
          indexName: "INDEX_NAME",
          searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(
              query: "query",
              aroundPrecision: SearchAroundPrecision.int(100)
          ))
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      index.Search(new Query("query")
      {
          AroundPrecision = 100 // 100 meters precision
      });
      ```

      ```go Go theme={"system"}
      res, err := index.Search(
        "query",
        opt.AroundPrecision(opt.AroundPrecisionRange{From: 0, Value: 100}) // 100 meters precision
      )
      ```

      ```java Java theme={"system"}
      index.search(new Query("").setAroundPrecision(
          Collections.singletonList(new AroundPrecision(0, 100)) // 100 meters precision
      ));
      ```

      ```js JavaScript theme={"system"}
      index
        .search("query", {
          aroundPrecision: 100, // 100 meters precision
        })
        .then(({ hits }) => {
          console.log(hits);
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val query = query("query") {
      aroundPrecision = AroundPrecision.Ranges(
          0 until 25, // 25 meters precision by default
          2000 until 1000 // 1,000 meters precision after 2 km
        )
      }

      index.search(query)
      ```

      ```php PHP theme={"system"}
      $results = $index->search('query', [
          'aroundPrecision' => 100 // 100 meters precision
      ]);
      ```

      ```python Python theme={"system"}
      results = index.search(
          "query",
          {
              "aroundPrecision": 100  # 100 meters precision
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      results = index.search(
        "query",
        {
          # 100 meters precision
          aroundPrecision: 100
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        search into "myIndex" query Query(
          query = Some("query"),
          aroundPrecision = Some(100) // 100 meters precision
        )
      }
      ```

      ```swift Swift theme={"system"}
      let query = Query("query")
        .set(\.aroundPrecision, to: [100]) // 100 meters precision

      index.search(query: query) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

### Specify range objects

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen>
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SearchSingleIndexAsync<Hit>(
        "INDEX_NAME",
        new SearchParams(
          new SearchParamsObject
          {
            Query = "query",
            AroundPrecision = new AroundPrecision(
              new List<Range>
              {
                new Range { From = 0, Value = 25 },
                new Range { From = 2000, Value = 1000 },
              }
            ),
          }
        )
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.searchSingleIndex(
        indexName: "INDEX_NAME",
        searchParams: SearchParamsObject(
          query: "query",
          aroundPrecision: [
            Range(
              from: 0,
              value: 25,
            ),
            Range(
              from: 2000,
              value: 1000,
            ),
          ],
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
        "INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
        search.NewEmptySearchParamsObject().SetQuery("query").SetAroundPrecision(search.ArrayOfModelRangeAsAroundPrecision(
          []search.ModelRange{*search.NewEmptyModelRange().SetFrom(0).SetValue(25), *search.NewEmptyModelRange().SetFrom(2000).SetValue(1000)})))))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      SearchResponse response = client.searchSingleIndex(
        "INDEX_NAME",
        new SearchParamsObject()
          .setQuery("query")
          .setAroundPrecision(
            AroundPrecision.of(Arrays.asList(new Range().setFrom(0).setValue(25), new Range().setFrom(2000).setValue(1000)))
          ),
        Hit.class
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({
        indexName: 'indexName',
        searchParams: {
          query: 'query',
          aroundPrecision: [
            { from: 0, value: 25 },
            { from: 2000, value: 1000 },
          ],
        },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams =
            SearchParamsObject(
              query = "query",
              aroundPrecision =
                AroundPrecision.of(
                  listOf(Range(from = 0, value = 25), Range(from = 2000, value = 1000))
                ),
            ),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->searchSingleIndex(
          'INDEX_NAME',
          ['query' => 'query',
              'aroundPrecision' => [
                  ['from' => 0,
                      'value' => 25,
                  ],

                  ['from' => 2000,
                      'value' => 1000,
                  ],
              ],
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "query": "query",
              "aroundPrecision": [
                  {
                      "from": 0,
                      "value": 25,
                  },
                  {
                      "from": 2000,
                      "value": 1000,
                  },
              ],
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index(
        "INDEX_NAME",
        Algolia::Search::SearchParamsObject.new(
          query: "query",
          around_precision: [
            Algolia::Search::Range.new(from: 0, value: 25),
            Algolia::Search::Range.new(from: 2000, value: 1000)
          ]
        )
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = Some(
            SearchParamsObject(
              query = Some("query"),
              aroundPrecision = Some(
                AroundPrecision(
                  Seq(
                    Range(
                      from = Some(0),
                      value = Some(25)
                    ),
                    Range(
                      from = Some(2000),
                      value = Some(1000)
                    )
                  )
                )
              )
            )
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response: SearchResponse<Hit> = try await client.searchSingleIndex(
          indexName: "INDEX_NAME",
          searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(
              query: "query",
              aroundPrecision: SearchAroundPrecision.arrayOfSearchRange([
                  SearchRange(from: 0, value: 25),
                  SearchRange(from: 2000, value: 1000),
              ])
          ))
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```php PHP theme={"system"}
      $results = $index->search('query', [
          'aroundPrecision' => [
              ['from' => 0, 'value' => 25], // 25 meters precision by default
              ['from' => 2000, 'value' => 1000] // 1,000 meters precision after 2 km
          ],
      ]);
      ```

      ```ruby Ruby theme={"system"}
      results = index.search(
        "query",
        {
          aroundPrecision: [
            # 25 meters precision by default
            {from: 0, value: 25},
            # 1,000 meters precision after 2 km
            {from: 2000, value: 1000}
          ]
        }
      )
      ```

      ```js JavaScript theme={"system"}
      index
        .search("query", {
          aroundPrecision: [
            { from: 0, value: 25 }, // 25 meters precision by default
            { from: 2000, value: 1000 }, // 1,000 meters precision after 2 km
          ],
        })
        .then(({ hits }) => {
          console.log(hits);
        });
      ```

      ```python Python theme={"system"}
      results = index.search(
          "query",
          {
              "aroundPrecision": [
                  {"from": 0, "value": 25},  # 25 meters precision by default
                  {"from": 2000, "value": 1000},  # 1,000 meters precision after 2 km
              ]
          },
      )
      ```

      ```swift Swift theme={"system"}
      let query = Query("query")
        .set(\.aroundPrecision, to: [
          .init(from: 0, value: 25), // 25 meters precision by default
          .init(from: 2000, value: 1000) // 1,000 meters precision after 2 km
        ])

      index.search(query: query) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```

      ```kotlin Kotlin theme={"system"}
      val query = query("query") {
          aroundPrecision = AroundPrecision.Int(100) // TODO: update snippet
      }

      index.search(query)
      ```

      ```cs C# theme={"system"}
      index.Search(new Query("query")
      {
          AroundPrecision = new List
          {
             new AroundPrecision { From = 0 , Value = 25 }, // 25 meters precision by default
             new AroundPrecision { From = 0 , Value = 1000 } // 1,000 meters precision after 2 km
          }
      });
      ```

      ```java Java theme={"system"}
      index.search(
        new Query("query")
          .setAroundPrecision(
              Arrays.asList(
                new AroundPrecision(0, 25),     // 25 meters precision by default
                new AroundPrecision(2000, 1000) // 1,000 meters precision after 2 km
              )
          )
      );
      ```

      ```go Go theme={"system"}
      res, err := index.Search(
      	"query",
      	opt.AroundPrecision(
      		opt.AroundPrecisionRange{From: 0, Value: 25},      // 25 meters precision by default
      		opt.AroundPrecisionRange{From: 2000, Value: 1000}, // 1,000 meters precision after 2 km
      	),
      )
      ```

      ```scala Scala theme={"system"}
      // The Scala API client does not support non-linear precision.
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
