import customTheme from "./theme"; import Layout from "./Layout"; export const theme = customTheme;
Here is a list of things that we need to scaffold the project
- Get Dataset
- ElasticSearch Cluster
- Import the dataset into ElasticSearch
- Bootstrap a React Project
- Install ReactiveSearch
- Connect to ElasticSearch with
<ReactiveBase />
Let's download sample dataset for Yelp
Ref: https://www.kaggle.com/yelp-dataset/yelp-dataset
We will be using Appbase.io to create ElasticSearch cluster
Appbase.io comes with great development tools,
which will allow us to quickly import the data
We will be using CodeSandbox to quickly Bootstrap the React project
yarn add @appbaseio/reactivesearch
Ref: https://docs.appbase.io/docs/reactivesearch/v3/overview/quickstart/
<ReactiveBase
app="yelp"
url="YOUR_ELASTICSEARCH_CLUSTER_URL"
>
// other components will go here.
<div>Hello ReactiveSearch!</div>
</ReactiveBase>
Ref: https://docs.appbase.io/docs/reactivesearch/v3/overview/quickstart/
In the next video we will see how to build Search for Yelp Data.
Let us once again see how
our Search UI would look alike
Now let us start building a Search box.
<DataSearch
componentId="SearchSensor"
dataField={["name", "name.search", "name.autosuggest"]}
onValueSelected={(value, cause, source) => {
console.log("value", value);
console.log("source", source);
}}
/>
Ref: https://docs.appbase.io/docs/reactivesearch/v3/search/datasearch/
Adding More fields to search
<DataSearch
componentId="SearchSensor"
dataField={[
"name",
"name.search",
"name.autosuggest",
"city",
"city.search",
"city.autosuggest"
]}
onValueSelected={(value, cause, source) => {
console.log("value", value);
console.log("source", source);
}}
/>
Adding field weights
<DataSearch
componentId="SearchSensor"
dataField={[
"name",
"name.search",
"name.autosuggest",
"city",
"city.search",
"city.autosuggest"
]}
fieldWeights={[3, 1, 1, 2, 1, 1]}
onValueSelected={(value, cause, source) => {
console.log("value", value);
console.log("source", source);
}}
/>
In the next video we will see how we can add category filter.
Let us once again see how
our Search + Filter UI would look alike
Now let us start building a Category Filter
<MultiList
componentId="CategorySensor"
dataField="categories.keyword"
/>
Ref: https://docs.appbase.io/docs/reactivesearch/v3/list/multilist/
In the next video we will see how we can add search results to our UI
Let us once again see how
our Search + Filter UI + Results would look alike
Now let us start building a Result UI.
<ReactiveList
componentId="SearchResult"
react={{
and: ['CategorySensor', 'SearchSensor'],
}}
renderItem={res => <div>{res.name}</div>}
/>
Ref: https://docs.appbase.io/docs/reactivesearch/v3/result/reactivelist/
Now let us see some more props that can help
us modify styles for the result easily
Ref: https://docs.appbase.io/docs/reactivesearch/v3/result/resultlist/
In the next video we will see how we can add Reactive Map to our UI
ReactiveMap helps us create a data-driven map UI component using Google Maps / Openstreet Map.
It is the key component for building map based experiences
Let us once again see how
our Search + Filter UI + Results + Map would look alike
Now let us start building a Map UI.
yarn add @appbaseio/reactivemaps
ReactiveMap is part of separate package, but still works
like any other ReactiveSearch Component
<ReactiveGoogleMap /><ReactiveOpenStreetMap />
We will be using <ReactiveOpenStreetMap /> to render the Map UI as it is free and open-source.
import { ReactiveOpenStreetMap } from '@appbaseio/reactivemaps';
<ReactiveOpenStreetMap
componentId="SearchResult"
react={{
and: ['CategorySensor', 'SearchSensor'],
}}
dataField="location"
/>
Ref: https://docs.appbase.io/docs/reactivesearch/v3/map/reactiveopenstreetmap/
In order to use OpenStreetMap / GoogleMap, we need to add their styles
in our index.html or you can import it in your codebase.
<link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet.css" rel="stylesheet" />
Now let us see some more props that can help
us modify styles for the result easily and help us avoid using
2 result component
Ref: https://docs.appbase.io/docs/reactivesearch/v3/result/resultlist/
In the next video we will explore some more features of Appbase.io
