Skip to content

Commit f1abe9c

Browse files
committed
expand facets, paging
1 parent f4e9b3c commit f1abe9c

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

articles/search/tutorial-javascript-search-query-integration.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,21 @@ The Azure Function pulls in the search configuration information, and fulfills t
4343

4444
Call the Azure Function in the React client with the following code.
4545

46-
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/pages/Search.js" highlight="80-101" :::
46+
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/pages/Search.js" highlight="88-100" :::
47+
48+
## Client: Facets from the catalog
49+
50+
This React component includes the search textbox and the [**facets**](search-faceted-navigation) associated with the search results. Facets need to be thought out and designed as part of the search schema when the search data is loaded. Then the facets are used in the search query, along with the search text, to provide the faceted navigation experience.
51+
52+
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/components/Facets/Facets.js" highlight="49-76" :::
53+
54+
## Client: Pagination from the catalog
55+
56+
When the search results expand beyond a trivial few (8), the `@mui/material/TablePagination` component provides **pagination** across the results.
57+
58+
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/components/Pager.js" highlight="27" :::
59+
60+
When the user changes the page, that value is sent to the parent `Search.js` page from the `handleChangePage` function. In the parent page, a change to the current page is detected which requires a new request is sent to the search API for the same query text and the new page. The API response results change the facets, results, and pager components.
4761

4862
## Azure Function: Suggestions from the catalog
4963

@@ -57,7 +71,13 @@ The search suggester, `sg`, is defined in the [schema file](https://github.com/A
5771

5872
The Suggest function API is called in the React app at `\src\components\SearchBar\SearchBar.js` as part of component initialization:
5973

60-
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/components/SearchBar.js" highlight="52-60" :::
74+
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/components/SearchBar.js" highlight="40-55, 75-117" :::
75+
76+
This React component uses the `@mui/material/Autocomplete` component to provide a search textbox, which also supports displaying suggestions (using the `renderInput` function) as the user types in characters. When each character is entered, the search is sent to API. The API results are displayed as a short list of suggestions.
77+
78+
This autosuggest functionality is a common feature but this specific implementation has an additional use case. The customer can enter text and select from the suggestions _or_ submit their entered text. The input from the suggestion list as well as the input from the textbox must be tracked for changes, which impact how the form is rendered and what is sent to the **search** API when the form is submitted.
79+
80+
If your use case for search allows your user to select only from the suggestions, that will reduce the scope of complexity of the control but limit the user experience.
6181

6282
## Azure Function: Get specific document
6383

@@ -69,7 +89,9 @@ The [Lookup API](https://github.com/Azure-Samples/azure-search-javascript-sample
6989

7090
This function API is called in the React app at `\src\pages\Details\Detail.js` as part of component initialization:
7191

72-
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/pages/Details.js" highlight="20-30" :::
92+
:::code language="javascript" source="~/azure-search-javascript-samples/search-website-functions-v4/client/src/pages/Details.js" highlight="17-21,28" :::
93+
94+
If your client app can use pregenerated content, this page is a good candidate for autogeneration because the content is static, pulled directly from the search index.
7395

7496
## Next steps
7597

0 commit comments

Comments
 (0)