This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm install -g create-react-app | |
| create-react-app video-game-search --use-npm | |
| cd video-game-search |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Step #1, import Statements | |
| import React from "react"; | |
| import AppSearchAPIConnector from "@elastic/search-ui-app-search-connector"; | |
| import { SearchProvider, Results, SearchBox } from "@elastic/react-search-ui"; | |
| import { Layout } from "@elastic/react-search-ui-views"; | |
| import "@elastic/react-search-ui-views/lib/styles/styles.css"; | |
| // Step #2, The Connector | |
| const connector = new AppSearchAPIConnector({ | |
| searchKey: "[YOUR_SEARCH_KEY]", | |
| engineName: "video-games", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import AppSearchAPIConnector from "@elastic/search-ui-app-search-connector"; | |
| import { SearchProvider, Results, SearchBox } from "@elastic/react-search-ui"; | |
| import { Layout } from "@elastic/react-search-ui-views"; | |
| import "@elastic/react-search-ui-views/lib/styles/styles.css"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "@elastic/react-search-ui-views/lib/styles/styles.css"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const connector = new AppSearchAPIConnector({ | |
| searchKey: "[YOUR_SEARCH_KEY]", | |
| engineName: "video-games", | |
| hostIdentifier: "[YOUR_HOST_IDENTIFIER]" | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const configurationOptions = { | |
| apiConnector: connector, | |
| searchQuery: { | |
| search_fields: { | |
| // 1. Search by name of video game. | |
| name: {} | |
| }, | |
| // 2. Results: name of the video game, its genre, publisher, scores, and platform. | |
| result_fields: { | |
| name: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function App() { | |
| return ( | |
| <SearchProvider config={configurationOptions}> | |
| <div className="App"> | |
| <Layout | |
| header={<SearchBox />} | |
| // titleField is the most prominent field within a result: the result header. | |
| bodyContent={<Results titleField="name" urlField="image_url" />} | |
| /> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { SearchProvider, Results, SearchBox } from "@elastic/react-search-ui"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| PagingInfo, | |
| ResultsPerPage, | |
| Paging, | |
| Facet, | |
| SearchProvider, | |
| Results, | |
| SearchBox, | |
| Sorting | |
| } from "@elastic/react-search-ui"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Layout | |
| header={<SearchBox />} | |
| bodyContent={<Results titleField="name" urlField="image_url" />} | |
| sideContent={ | |
| <div> | |
| <Sorting | |
| label={"Sort by"} | |
| sortOptions={[ | |
| { | |
| name: "Relevance", |