This topic describes the syntax of geo functions. This topic also provides examples on how to use the functions.

Notice If you want to use strings in analytic statements, you must enclose strings in single quotation marks (''). Strings that are not enclosed or enclosed in double quotation marks ("") indicate field names or column names. For example, 'status' indicates the status string, and status or "status" indicates the status log field.
Function Syntax Description
geohash function geohash(x) Encodes latitudes and longitudes by using the Geohash algorithm.
Note Log Service allows you to convert IP addresses into geographic location information such as countries, provinces, cities, operators, and latitudes and longitudes. For more information, see IP functions.

geohash function

The geohash function encodes latitudes and longitudes by using the Geohash algorithm.

Syntax

geohash(x)

Parameters

Parameter Description
x The value of this parameter is of the string type. The value indicates a latitude and a longitude. Example: ip_to_geo(latitude,longitude).

Return value type

The string type

Examples

Use the ip_to_geo function to convert the value of the client_ip field into a latitude and a longitude. Then, use the geohash function to encode the latitude and longitude.

  • Query statement
    * | SELECT geohash(ip_to_geo(client_ip)) AS hash
  • Query and analysis resultsgeohash