Search docs

Autocomplete

Search as you type, with an unfinished last word.

By · Updated

GET /v1/autocomplete is like /v1/search, but the last word of text is treated as unfinished and matches as a prefix. shaniwar wa finds Shaniwar Wada.

Parameters

ParameterTypeDefaultMeaning
textstringrequiredPlace name, address, or both. Only letters and digits count; at most 12 words are used.
sizeinteger 1–4010Number of results.
layerslistallComma-separated: venue (points of interest), address, street (no geolith build writes streets yet), locality (cities, towns, villages), county, region, country.
boundary.countrylistevery countryComma-separated ISO 3166-1 alpha-2 codes, any case.
focus.point.latnumber −90–90noneLatitude of a point whose surroundings rank higher. Set with focus.point.lon.
focus.point.lonnumber −180–180noneLongitude of that point. Set with focus.point.lat.

Example

curl 'http://localhost:4000/v1/autocomplete?text=shaniwar%20wa&size=2'
{
  "bbox": [
    73.8490348,
    18.5196488,
    73.855376,
    18.5232435
  ],
  "features": [
    {
      "geometry": {
        "coordinates": [
          73.855376,
          18.5196488
        ],
        "type": "Point"
      },
      "properties": {
        "confidence": 1.0,
        "country": "India",
        "country_code": "IN",
        "county": "Pune",
        "gid": "geolith:venue:5690416219557866379",
        "id": "5690416219557866379",
        "importance": 0.9390000104904175,
        "label": "Shaniwar Wada, Pune, Maharashtra, India",
        "layer": "venue",
        "locality": "Pune",
        "name": "Shaniwar Wada",
        "region": "Maharashtra",
        "source": "geolith"
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "coordinates": [
          73.8490348,
          18.5232435
        ],
        "type": "Point"
      },
      "properties": {
        "confidence": 1.0,
        "country": "India",
        "country_code": "IN",
        "county": "Pune",
        "gid": "geolith:venue:7254043780672488050",
        "id": "7254043780672488050",
        "importance": 0.9943000078201294,
        "label": "Hotel Swan Inn Near Shaniwar Wada, Pune, Maharashtra, India",
        "layer": "venue",
        "locality": "Pune",
        "name": "Hotel Swan Inn Near Shaniwar Wada",
        "region": "Maharashtra",
        "source": "geolith"
      },
      "type": "Feature"
    }
  ],
  "geocoding": {
    "attribution": "https://console.geolith.app/attribution",
    "engine": {
      "name": "geolith-search",
      "version": "0.1.0"
    },
    "query": {
      "ranking": "importance",
      "size": 2,
      "text": "shaniwar wa"
    },
    "version": "0.2"
  },
  "type": "FeatureCollection"
}

The response is trimmed to two features.

How the last word matches

  • The last word matches as a prefix. The file keeps a posting list for every word prefix of 4 to 6 characters, and a short list of the most important places for every prefix of 2 or 3 characters, so a lone short prefix reads one list. After other words, a 2- or 3-character prefix is checked against a small prefix signature stored with each place, and a 1-character last word is checked on the place text.
  • The last word stays required even when the other words relax.
  • The other words match as whole words.