Geospatial Search

What is Geospatial Search?

Geospatial search is the use of geographical coordinates to enable searching based upon the "position" of documents. For example:

  • A news item search might enable locating news stories reported for areas close to a certain location
  • A shop search might enable locating stores and retailers located close to the searcher

Geospatial search requires that documents contain geospatial data and Funnelback is configured to use geosaptial data.

Providing geospatial data to Funnelback

Documents in geospatial search collections must have a geospatial location specified through metadata in latitude and longitude format. Latitude and longitude must be represented in decimal degrees (i.e. not minutes and seconds).

<meta name="geo.position" content="-37.4500;146.0833" />

Proximity-based relevance ranking and proximity filtering are insensitive to which geodesic datum is used, but do assume that the origin given to padre and the coordinates applied to documents are expressed relative to the same datum.

If the user-supplied origin is expected to come from a GPS device, the origin will be expressed in the WGS84 system and documents should ideally be marked up according to the same system.

If a document's geospatial position is not specified, that document's position is assumed to be 0,0.

To use geospatial search you must map both latitude and longitude to a single metadata class using metamap.cfg with a content flag of "2".

For example, to map the latitude and longitude from the <meta name="geo.position"/> tag:


Once geospatial metadata has been defined for documents within the collection, and mapped using the metamap.cfg, the collection should be updated or reindexed. After reindexing, the geospatial data is available for searching.

Geospatial metadata and meta collections

If the collection is part of a meta collection you must ensure that you configure the other collections to have the same geospatial metadata class otherwise incompatible indexes will be produced. For example if 'latLong' is defined as type 2 metadata in one collection, all other component collections within the meta collection must also have the 'latLong' field defined as type 2, even if no geospatial metadata is available in those component collections.

Detecting Users' Locations

Funnelback attempts to detect a user's location automatically via their remote IP address, making this information available in the data model:

 question: {
   "location": {
     "areaCode": 0,
     "city": "London",
     "countryCode": "GB",
     "countryName": "United Kingdom",
     "dmaCode": 0,
     "latitude": 51.514206,
     "longitude": -0.09309387,
     "metroCode": 0,
     "postalCode": null,
     "region": "H9"

The latitude and longitude values are assumed to be the default origin value for any subsequent query, and are used for calculating each geocoded result's kmFromOrigin value.

Automatically-detected locations can be overridden by manually specifying an origin, which can be performed in tandem with modern user agents' implementation of the HTML5 GeoLocation API.

Query options

Once geospatial search is configured, several additional query processor options are available for use. These options are mirrored through the public search interface.


specifies origin of search. Overrides the automatically-detected user location.


sort matching results by geospatial proximity / descending geospatial proximity to origin


filter out results that are more than x kilometers from the origin


When a geospatial metadata class is given to the -rmrf option, a bounding box for all matching documents will be returned in the data model, for example -rmrf=[latLong].

Display Options

After a geospatial search query has been performed, additional elements in the data model are available for display using search form syntax.

To display results' latitude and longitude values can be displayed as standard metadata:

 <#if s.result.metaData["latLong"]??>Lat/Long: ${s.result.metaData["latLong"]!}</#if>

To display result's distance from the origin can also be displayed using a similar approach:

 <#if s.result.kmFromOrigin??>${s.result.kmFromOrigin} km away</#if>

To display the upper right coordinates of the bounding box for metadata class "latLong":

 ${response.resultPacket.boundingBoxes["latLong"].upperRight.latitude!}, ${response.resultPacket.boundingBoxes["latLong"].upperRight.longitude!}.

To display the lower left coordinates of the bounding box for metadata class "latLong":

 ${response.resultPacket.boundingBoxes["latLong"].lowerLeft.latitude!}, ${response.resultPacket.boundingBoxes["latLong"].lowerLeft.longitude!}.

See also