Loading...

Search

OfflineSearch provides built-in search capability for the Mappedin React Native SDK v5. It is exposed as a property of the MapViewStore class and indexes the locations and categories for an easy-to-use search feature. This lightweight but capable search engine only requires one line to query.

const results = await mapView.current.OfflineSearch.search("Foo");

A Searchable Directory

The following video demonstrates a directory listing of tenants in the Mappedin Demo Mall. Running on both Android and iOS, the search quickly filters the list to only display relevant results. Selecting an item will cause the map to highlight and zoom on the listed location.

The code for this demo is available as part of Mappedin's React Native demo application on GitHub.

Search Settings

The search parameters can be tweaked with following constants, which are described in TMappedinOfflineSearchAllOptions. The default values were chosen to prioritize the primary index, for a balanced indexing time and to provide some fuzziness to account for possible typos in search queries.

{
CATEGORY_LOCATION_DESCRIPTION_WEIGHT: number;
CATEGORY_LOCATION_NAME_WEIGHT: number;
CATEGORY_LOCATION_TAGS_WEIGHT: number;
CATEGORY_NAME_WEIGHT: number;
LOCATION_DEFAULT_RANK: number;
LOCATION_NAME_WEIGHT: number;
PRIMARY_INDEX_FUZZYNESS: number;
PRIMARY_INDEX_TAGS_NAME_WEIGHT: number;
PRIMARY_INDEX_WEIGHT: number;
RATIO_OF_FUZZY_TO_EXACT: number;
RATIO_OF_PREFIX_TO_EXACT: number;
SECONDARY_INDEX_WEIGHT: number;
}

Location names, descriptions, categories and tags are searched by default. You can also opt-in for deeper indexing with the following options. Using them will increase the indexing time, however so they're not turned on by default.

  • searchDescriptionsInCategories to additionally index all tags for every location in every category
  • searchTagsInCategories to also index all tags for every location in every category

To adjust these parameters, provide a value for searchOptions at initialization of the <MiMapView />.

<MiMapView
key="mappedin"
ref={mapView}
options={{
// See Trial API key Terms and Conditions
// https://developer.mappedin.com/api-keys/
venue: "mappedin-demo-mall",
clientId: "5eab30aa91b055001a68e996",
clientSecret: "RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
searchOptions: {
// ... search parameters
},
}}
/>

Additional Reading

Was this page helpful?