Search Definitions¶
Search definitions define what searches are available in the search bar and how they work.
Relevant tables¶
Table Name | Description |
---|---|
SearchDefinitions | Contains details of the searches that can be used in versions |
VersionSearchDefinition | Mapping between search definitions and versions, showing which search definitions are available in which version |
SearchDefinitions¶
This table contains all the details about the available search definitions.
The first block of columns is the basic details.
Name
- A friendly name for administratorsTitle
- The name that will appear in the search results listAttributionHtml
- Optional HTML to add to the bottom of the search results as an attributionMaxResults
- The maximum number of results to return from the serviceZoomLevel
- The zoom level to zoom to when a user clicks a search result. Optional if a geometry path, column or minimum bounding rectangle is definedEPSG
- The EPSG code of the geometry returnedValidationRegex
- An optional Regular Expression to validate the search query against. If a search query doesn't match the regualr expression, it won't even be attempted. Leave blank for no validationSupressGeom
- A boolean indicating if the returned geometry should be supressed or not. This prevents a pin, line or polygon from being drawn on the map when a user clicks on a search result
The next block of columns are filled in depending on the `Discriminator' column. These are different depending on the type of search definition you are creating.
Discriminator
- Defines the type of search definition this is. There are 3 possible options:APISearchDefinition
- Defines a search that calls a remote web APIDatabaseSearchDefinition
- Defines a search that uses a locally accessible database tableLocalSearchDefinition
- Definies a search that is built in to the application itself.
APISearchDefinition¶
If you choose APISearchDefinition
, the following columns are relevant:
Note
Only GET
requests that return JSON are currently supported for API calls
URLTemplate
- The full URL to do the search, with the placeholder {{search}} where the search query would goXFieldPath
- A JSONPath expression to an appropriate 'X' field in the JSON. Optional if you useGeomFieldPath
or theMBRPath...
columns.YFieldPath
- A JSONPath expression to an appropriate 'Y' field in the JSON. Optional if you useGeomFieldPath
or theMBRPath...
columns.TitleFieldPath
- A JSONPath expression to an appropriate 'Title' field, used for displaying the search result.GeomFieldPath
- A JSONPath expression to appopriate 'Geometry' field. The geometry must be valid GeoJSON. Optional if you useXFieldPath
/YFieldPath
or theMBRPath...
columns.MBRXMinPath
- A JSONPath expression to an appropriate bottom left X coordinate minimum bounding rectangle field. Optional if you useXFieldPath
/YFieldPath
orGeomFieldPath
.MBRXMaxPath
- A JSONPath expression to an appropriate top right X coordinate minimum bounding rectangle field. Optional if you useXFieldPath
/YFieldPath
orGeomFieldPath
.MBRYMinPath
- A JSONPath expression to an appropriate bottom left Y coordinate minimum bounding rectangle field. Optional if you useXFieldPath
/YFieldPath
orGeomFieldPath
.MBRYMaxPath
- A JSONPath expression to an appropriate top right Y coordinate minimum bounding rectangle field. Optional if you useXFieldPath
/YFieldPath
orGeomFieldPath
.
Info
JSONPath
is a query language for JSON, similar to XPath for XML. It allows you to select and extract data from a JSON document. You can use tools such as JSON Path Finder or JSONPath Online Evaluator to build JSONPath expressions.
DatabaseSearchDefinition¶
If you choose `DatabaseSearchDefinition , the following columns are relevant:
TableName
- The fully qualified name of the table to queryXField
- The name of an appropriate 'X' column in the tableYField
- The name of an appropriate 'Y' column in the tableGeomField
- The name of an appopriate GeoJSON geometry column in the table. You may need to use a database function to convert the geometry to GeoJSON, such as Postgres'ST_AsGeoJson(geom)
TitleField
- The name of an appropriate 'Title' field, used for displaying the search result.WhereClause
- TheWHERE
clause used to do the actual search, with the placeholder {{search}} where the search query would goOrderByClause
- An optionalORDER BY
to append to the query
Note
The same user that is used to access the GIFramework Maps database must be able to access the tables you use in these search definitions. You may want to consider using foreign tables to avoid duplicating data
LocalSearchDefinition¶
LocalSearchDefinition
s are a little different. These refer to searches that are in-built to the application, and have specific names. The only relevant column is LocalSearchName
, which refers to the hard-coded name in the application. The following in-built searches are available:
BNG12Figure
- Searches for 12 Figure British National Grid coordinatesBNGAlphaNumeric
- Searches for British National Grid Alphanumeric coordinatesLatLonDecimal
- Searches for Latitiude/Longitude coordinates in Decimal formatLatLonDMS
- Searches for Latitiude/Longitude coordinates in Degrees/Minutes/Seconds formatSphericalMercator
- Searches for Spheric Mercator (EPSG:3857) coordinatesPlusCode
- Searches for PlusCodes
VersionSearchDefinition¶
The VersionSearchDefinition
table defines which searches are available in which versions.
VersionId
- TheId
from theVersions
tableSearchDefinitionId
- TheId
from theSearchDefinition
tableEnabled
- A boolean indicating whether this search is enabled by default (users can override this in the search options dialog)Order
- The order in which the search results are searched. Particularly important if theStopIfFound
boolean is usedStopIfFound
- Determines whether the further searches are conducted if a result has been found with this search
Example
When you do a search, GIFramework Maps starts from the top of the list (sorted by the Order
column) and works its way down until it finds a result. When it does, if the StopIfFound
boolean is set to true, GIFramework Maps will not continue with any of the other searches. This prevents users from getting lots of potentially irrelevant results when a more relevant result has already been found.
Note
If a specific search definition configuration is not found for a version, it will fall back to using search definitions defined for the 'general' version