Skip to content

Search Web Service

(Stein) Runar Bergheim edited this page Apr 19, 2016 · 3 revisions

The search web service supports the following four parameters

  • q (mandatory): any textual search term, can be multi-words and can be partial with * as a wildcard character
  • layers (optional): a comma separated list of layers names that the search will be limited to
  • maxresults (optional): the maximum number of results to return from a search, defaults to 25
  • extent (optional): the desired extent - results whose bounding box intersects with this extent will be given a higher rating than other results

The response for queries is always a JSON object with an array called data that contains the search results and a number of other properties including a count, the time taken by the query, the query string parameters etc.

Each search result has a 'Score' that determines its relevance, a 'FullGeom' that is a copy of the feature geometry as it was in the source file transformed to SRS EPSG:4326 and a 'PointGeom' that is a point on a geometry (i.e. for points the same point, for lines a point on the line and for polygons an point on the polygon)

The content of the 'DisplayTitle' and 'DisplayDescription' fields depends on the indexing configuration applied for the individual layer being indexed.

Example request

The Web Service implements CORS and accepts all clients by default. It can be called from any JavaScript or HTTP client. It supports both Http GET and POST requests.

Calling the service from the address line in your web browser:

http://localhost:8080/openapi/search?q=Brussels&maxresults=1

Calling the service using the s4a.js client-side JavaScript library:

var myQuery = new s4a.ir.QueryHelper();

var myQueryResults = myQuery
    .setQuery(‘Brussels’)
    .setMaxResults(1)
    .query() // Function returns a jQuery ‘Promise’

myQueryResults.then(function(response) {
     // Do something with the query results
};

Example response

{
	"data":[
		{
			"Score":10.037248,
			"Id":"Geonames 1000-6447",
			"Layer":"Geonames 1000",
			"ObjType":"names",
			"FullGeom":"POINT (4.34878 50.85045)",
			"PointGeom":"POINT (4.34878 50.85045)",
			"DisplayTitle":"Brussels",
			"DisplayDescription":"Alternative forms: An Bhruiseil,An Bhruiséil,BRU,Breissel,Brisel,Brisele,Briuselis,Brjuksel,Brjusel',Brjussel',Brueksel,Bruessel,Bruesszel,Bruiseal,Bruksel,Bruksela,Brukseli,Brukselo,Brusehl',Brusel,Brusela,Bruselas,Bruseles,Bruselj,Bruselo,Brusel·les,Brussel,Brussele,Br. Type of name PPLC in Europe/Brussels",
			"JsonData":{}
		}
	],
	"status":"success",
	"count":1,
	"messages":[],
	"time":10,
	"parameters":"q=Brussels&maxresults=1"
}
Clone this wiki locally