aroundLatLngViaIP

Type: boolean
Engine default: false
Parameter syntax
'aroundLatLngViaIP' => true|false
Parameter syntax
aroundLatLngViaIP: true|false
Parameter syntax
aroundLatLngViaIP: true|false
Parameter syntax
'aroundLatLngViaIP': True|False
Parameter syntax
"aroundLatLngViaIP": true|false
Parameter syntax
.setAroundLatLngViaIP(true|false)
Parameter syntax
.AroundLatitudeLongitudeViaIP()
Parameter syntax
.setAroundLatLngViaIP(true|false)
Parameter syntax
"aroundLatLngViaIP": true|false
Parameter syntax
aroundLatLngViaIP = Some(true|false)

Can be used in these methods:
search, browseObjects, searchForFacetValues, generateSecuredApiKey, addApiKey, updateApiKey search, browse, search_for_facet_values, generate_secured_api_key, add_api_key, update_api_key search, browse, searchForFacetValues, generateSecuredApiKey, addApiKey, updateApiKey search, browse, search_for_facet_values, generate_secured_api_key, add_api_key, update_api_key search, browse, searchForFacetValues searchAsync, browseAsync, searchForFacetValues Search, Browse, SearchForFacetValues, GenerateSecuredApiKey, AddApiKey, UpdateApiKey Search, browse, searchForFacetValues, generateSecuredApiKey, addApiKey, updateApiKey Search, Browse, SearchForFacetValues, GenerateSecuredAPIKey, AddAPIKey, UpdateAPIKey search, browse index, search into facet values, generateSecuredApiKey, add key, update key

About this parameter

Search for entries around a given location automatically computed from the requester’s IP address.

By computing a central geolocation (from an IP), this has three consequences:

  • a radius / circle is computed automatically, based on the density of the records near the point defined by this setting
  • only records that fall within the bounds of the circle are returned
  • records are ranked according to the distance from the center of the circle

Usage notes:
  • With this setting, you are using the end-user’s IP to define a central axis point of a circle in geo-coordinates.

  • Algolia automatically calculates the size of the circular radius around this central axis.

  • If you are sending the request from your servers, you must set the X-Forwarded-For HTTP header with the front-end-user’s IP address for it to be used as the basis for the computation of the search location.

  • Note: This setting differs from aroundLatLng, which allows you to specify the exact latitude and longitude of the center of the circle.

  • This parameter will be ignored if used along with insideBoundingBox or insidePolygon

  • We currently only support IPv4 addresses. If the end user has an IPv6 address, this parameter won’t work as intended.

Examples

Search around user’s IP

<?php
/*
'94.228.178.246' should be replaced with the actual IP you would like
to search around. Depending on your stack there are multiple ways to get this
information.
*/
$ip = '94.228.178.246';

$client = new \AlgoliaSearch\Client(
  'YourApplicationID',
  'YourSearchOnlyAPIKey'
);

$client->setExtraHeader('X-Forwarded-For', $ip);

$index = $client->initIndex('index_name');

$results = $index->search('query', [
  'aroundLatLngViaIP' => true
]);
# '94.228.178.246' should be replaced with the actual IP you would like
# to search around. Depending on your stack there are multiple ways to get this
# information.

ip = '94.228.178.246'

client = Algolia::Client.new(
  application_id: 'YourApplicationID',
  api_key: 'YourSearchOnlyAPIKey'
)

client.set_extra_header 'X-Forwarded-For', ip

index = client.init_index 'index_name'

results = index.search('query', {
  aroundLatLngViaIP: true
})
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
// This is only needed when you're making a request from Node.js. If you make
// your request in the browser, then this is added automatically.
client.setExtraHeader('X-Forwarded-For', '94.228.178.246');

index.search({
  aroundLatLngViaIP: true
}).then(res => {
  // console.log(res);
});
# '94.228.178.246' should be replaced with the actual IP you would like
# to search around. Depending on your stack there are multiple ways to get this
# information.
ip = '94.228.178.246'

client.set_extra_headers('X-Forwarded-For', ip)

results = index.search('query', {
    'aroundLatLngViaIP': True
})
/// '94.228.178.246' should be replaced with the actual IP you would like
/// to search around. Depending on your stack there are multiple ways to get this
/// information.
client.setHeader(withName: "X-Forwarded-For", to: "94.228.178.246")

let query = Query(query: "query")
query.aroundLatLngViaIP = true

index.search(query, completionHandler: { (res, error) in
  print(res)
})
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
client.setHeader("X-Forwarded-For", "94.228.178.246")

index.search(
  new Query("query").setAroundLatLngViaIP(true)
);
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
client.SetExtraHeader("X-Forwarded-For", "94.228.178.246");

index.search(
  new Query("query")
    .AroundLatitudeLongitudeViaIP()
);
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.

index.search(
  new Query("query")
    .setAroundLatLngViaIP(true),
  new RequestOptions()
    .addExtraHeader("X-Forwarded-For", "94.228.178.246")
);
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
client.SetExtraHeader("X-Forwarded-For", "94.228.178.246")

res, err := index.Search("query", algoliasearch.Map{
  "aroundLatLngViaIP": true,
})
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.

client.execute {
  search into "myIndex" query Query(
    query = Some("query"),
    aroundLatLngViaIP = Some(true)
  ) options RequestsOptions(
    extraHeaders = Some(Map("X-Forwarded-For" -> "94.228.178.246"))
  )
}
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala