GeoSearch.Init Tutorial
Limiting Search Results to a Domain
site Keyword
To only show search results from a specific domain, we add the text "site:example.com" to the end of our search text, and all search results returned will be from the domain "example.com".
To try this out, load this example and follow the instructions.
metadata Keyword
The metadata keyword is most likely to be useful to users who are using a MetaCarta GTS.
In addition to the site: keyword, GeoSearch supports all other MetaCarta appliance keywords, including the metadata keyword. This keyword allows you to limit your search to documents which match a certain piece of metadata, as determined when ingested.
To filter your search on metadata, you need to include text of the form:
metadata:key=value
To learn how to discover what metadata is available from your system, read about using the JSON Explorer to determine existing metadata.
searchParams
To configure GeoSearch to automatically limit the search results to a certain domain or metadata value, we will need to pass a new parameter to the GeoSearch.Init() function called "searchParams".
This parameter allows us to specify a list of extra text strings to be appended to each search query made from the page. For example, if we wanted every search on our page to be searching for the word chicken (as well as whatever text the user types in the search box) we would do something like this:
MetaCarta.GeoSearch.Init({'textDivId': 'list',
'mapDivId': 'map',
'searchParams': ['chicken']
});
Now if the user types "pheasant" in the search field, the real query that will be sent out will be "pheasant chicken".
To try this out, load this example and follow the instructions.
As you can probably guess, however, that sort of thing wouldnt make very much sense.
searchParams and site Combined
We can, however, use the searchParams field to limit the search results to a specific domain.
If we want to limit searches to the BP's website (bp.com), for example, we pass in "site:bp.com" as one of the searchParams.
MetaCarta.GeoSearch.Init({'textDivId': 'list',
'mapDivId': 'map',
'searchParams': ['site:bp.com']
});
See this example live.
Previous: Turning GeoSearch On | Next: Integrating with External GUI