Search Class
A class to access the Mappedin Search API. This will be created for you as part of Mappedin.Mappedin/initailize:method, but you can also create one manually.
Properties
-
query
-
options
Makes a call to the Mappedin Smart Search API with the provided query, retuning a Promise that will fulfill with a
SearchResults object. This will contain a list of hits
, which can currently be SearchItems (either SearchLocations or SearchEvents).
These are currently different from the objects you get directly from the Mappedin API, containing a subset of their data, but you can match on their IDs.
The data is broken down into pages. You can specify the size (defaults to 10).
Parameters:
-
query
StringThe string to search for
-
[options]
Object optionalAny optional parameters you need to pass to the search API
-
[ps]
Number optionalNumber of search results to return. Defaults to 10. You can get the next page from SearchResults.next
-
[type]
ASSET_TYPE optionalIf you want to limit your results to a specific type of SearcItem, specify it here. Currently either ASSET_TYPES.LOCATION or ASSET_TYPES.EVENT
-
Returns:
The promise will resolve with either a SearchResults object if successful, or an error with a message
and status
if it fails
SearchResults has the following propertyies and methods:
query: The search query that triggered this search
total: The total number of results.
hits: The array of SearchItems in the current page.
A SearchItem is an object that contains an id property that could match the id of a Location or Event on your Venue object. This is NOT GUARANTEED, however, as the data could have changed since the getVenue call was performed.
nextPage() -> A promise that will resolve with the next page of SearchResults
-
query
Makes a call to the Mappedin Smart Search Suggestions API with the provided query, retuning a Promise that will fulfill with a
Suggestions object. This will contain a list of hits
, which are words that match full search results. This should be used
to aid in autocoplete for a search bar. It's ordered for you by most relevant.
Parameters:
-
query
StringThe string to get autocomplete suggestions for
Returns:
The promise will resolve with either a Suggestions object if successful, or an error with a message
and status
if it fails
Suggestions has the following propertyies and methods:
query: The suggestion query that triggered this list of suggestions (to make sure it's still what's in the text bar)
total: The total number of suggestions.
hits: The array of Strings matching the query