You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Faceted navigation is an alternative entry point to search. It offers a convenient alternative to typing complex search expressions by hand. Facets can help you find what you're looking for, while ensuring that you don’t get zero results. As a developer, facets let you expose the most useful search criteria for navigating your search index. In online retail applications, faceted navigation is often built over brands, departments (kid’s shoes), size, price, popularity, and ratings.
19
+
Faceted navigation is an alternative entry point to search. It offers a convenient alternative to typing complex search expressions by hand. Facets can help you find what you're looking for, while ensuring that you don't get zero results. As a developer, facets let you expose the most useful search criteria for navigating your search index. In online retail applications, faceted navigation is often built over brands, departments (kid's shoes), size, price, popularity, and ratings.
20
20
21
21
Implementing faceted navigation differs across search technologies. In Azure Cognitive Search, faceted navigation is built at query time, using fields that you previously attributed in your schema.
22
22
@@ -29,16 +29,16 @@ In your application development, writing code that constructs queries constitute
29
29
## Sample code and demo
30
30
This article uses a job search portal as an example. The example is implemented as an ASP.NET MVC application.
31
31
32
-
- See and test the working demo online at [Azure Cognitive Search Job Portal Demo](http://azjobsdemo.azurewebsites.net/).
32
+
- See and test the working demo online at [Azure Cognitive Search Job Portal Demo](https://aka.ms/azjobsdemo).
33
33
34
34
- Download the code from the [Azure-Samples repo on GitHub](https://github.com/Azure-Samples/search-dotnet-asp-net-mvc-jobs).
35
35
36
36
## Get started
37
-
If you're new to search development, the best way to think of faceted navigation is that it shows the possibilities for self-directed search. It’s a type of drill-down search experience, based on predefined filters, used for quickly narrowing down search results through point-and-click actions.
37
+
If you're new to search development, the best way to think of faceted navigation is that it shows the possibilities for self-directed search. It's a type of drill-down search experience, based on predefined filters, used for quickly narrowing down search results through point-and-click actions.
38
38
39
39
### Interaction model
40
40
41
-
The search experience for faceted navigation is iterative, so let’s start by understanding it as a sequence of queries that unfold in response to user actions.
41
+
The search experience for faceted navigation is iterative, so let's start by understanding it as a sequence of queries that unfold in response to user actions.
42
42
43
43
The starting point is an application page that provides faceted navigation, typically placed on the periphery. Faceted navigation is often a tree structure, with checkboxes for each value, or clickable text.
44
44
@@ -73,9 +73,9 @@ Complex search expressions decrease the performance of the query. Where possible
73
73
To better understand how a filter adds more precision, compare a complex search expression to one that includes a filter expression:
-`GET /indexes/hotel/docs?search=lodging&$filter=City eq ‘Seattle’ and Parking and Type ne ‘motel’`
76
+
-`GET /indexes/hotel/docs?search=lodging&$filter=City eq 'Seattle' and Parking and Type ne 'motel'`
77
77
78
-
Both queries are valid, but the second is superior if you’re looking for non-motels with parking in Seattle.
78
+
Both queries are valid, but the second is superior if you're looking for non-motels with parking in Seattle.
79
79
- The first query relies on those specific words being mentioned or not mentioned in string fields like Name, Description, and any other field containing searchable data.
80
80
- The second query looks for precise matches on structured data and is likely to be much more accurate.
81
81
@@ -102,9 +102,9 @@ In the following sections, we take a closer look at how to build each part.
102
102
103
103
## Build the index
104
104
Faceting is enabled on a field-by-field basis in the index, via this index attribute: `"Facetable": true`.
105
-
All field types that could possibly be used in faceted navigation are `Facetable` by default. Such field types include `Edm.String`, `Edm.DateTimeOffset`, and all the numeric field types (essentially, all field types are facetable except `Edm.GeographyPoint`, which can’t be used in faceted navigation).
105
+
All field types that could possibly be used in faceted navigation are `Facetable` by default. Such field types include `Edm.String`, `Edm.DateTimeOffset`, and all the numeric field types (essentially, all field types are facetable except `Edm.GeographyPoint`, which can't be used in faceted navigation).
106
106
107
-
When building an index, a best practice for faceted navigation is to explicitly turn faceting off for fields that should never be used as a facet. In particular, string fields for singleton values, such as an ID or product name, should be set to `"Facetable": false` to prevent their accidental (and ineffective) use in faceted navigation. Turning faceting off where you don’t need it helps keep the size of the index small, and typically improves performance.
107
+
When building an index, a best practice for faceted navigation is to explicitly turn faceting off for fields that should never be used as a facet. In particular, string fields for singleton values, such as an ID or product name, should be set to `"Facetable": false` to prevent their accidental (and ineffective) use in faceted navigation. Turning faceting off where you don't need it helps keep the size of the index small, and typically improves performance.
108
108
109
109
Following is part of the schema for the Job Portal Demo sample app, trimmed of some attributes to reduce the size:
110
110
@@ -134,7 +134,7 @@ Following is part of the schema for the Job Portal Demo sample app, trimmed of s
134
134
}
135
135
```
136
136
137
-
As you can see in the sample schema, `Facetable` is turned off for string fields that shouldn’t be used as facets, such as ID values. Turning faceting off where you don’t need it helps keep the size of the index small, and typically improves performance.
137
+
As you can see in the sample schema, `Facetable` is turned off for string fields that shouldn't be used as facets, such as ID values. Turning faceting off where you don't need it helps keep the size of the index small, and typically improves performance.
138
138
139
139
> [!TIP]
140
140
> As a best practice, include the full set of index attributes for each field. Although `Facetable` is on by default for almost all fields, purposely setting each attribute can help you think through the implications of each schema decision.
@@ -227,7 +227,7 @@ SearchParameters sp = new SearchParameters()
227
227
228
228
A facet query parameter is set to a field and depending on the data type, can be further parameterized by comma-delimited list that includes `count:<integer>`, `sort:<>`, `interval:<integer>`, and `values:<list>`. A values list is supported for numeric data when setting up ranges. See [Search Documents (Azure Cognitive Search API)](https://docs.microsoft.com/rest/api/searchservice/Search-Documents) for usage details.
229
229
230
-
Along with facets, the request formulated by your application should also build filters to narrow down the set of candidate documents based on a facet value selection. For a bike store, faceted navigation provides clues to questions like *What colors, manufacturers, and types of bikes are available?*. Filtering answers questions like *Which exact bikes are red, mountain bikes, in this price range?*. When you click "Red" to indicate that only Red products should be shown, the next query the application sends includes `$filter=Color eq ‘Red’`.
230
+
Along with facets, the request formulated by your application should also build filters to narrow down the set of candidate documents based on a facet value selection. For a bike store, faceted navigation provides clues to questions like *What colors, manufacturers, and types of bikes are available?*. Filtering answers questions like *Which exact bikes are red, mountain bikes, in this price range?*. When you click "Red" to indicate that only Red products should be shown, the next query the application sends includes `$filter=Color eq 'Red'`.
231
231
232
232
The following code snippet from the `JobsSearch.cs` page adds the selected Business Title to the filter if you select a value from the Business Title facet.
233
233
@@ -266,7 +266,7 @@ If you build the list of facets dynamically based on untrusted user input, valid
266
266
### Filtering tips
267
267
**Increase search precision with filters**
268
268
269
-
Use filters. If you rely on just search expressions alone, stemming could cause a document to be returned that doesn’t have the precise facet value in any of its fields.
269
+
Use filters. If you rely on just search expressions alone, stemming could cause a document to be returned that doesn't have the precise facet value in any of its fields.
270
270
271
271
**Increase search performance with filters**
272
272
@@ -293,7 +293,7 @@ In general, if you find that facet results are consistently too large, we recomm
293
293
294
294
For each faceted field in the navigation tree, there is a default limit of 10 values. This default makes sense for navigation structures because it keeps the values list to a manageable size. You can override the default by assigning a value to count.
295
295
296
-
*`&facet=city,count:5` specifies that only the first five cities found in the top ranked results are returned as a facet result. Consider a sample query with a search term of “airport” and 32 matches. If the query specifies `&facet=city,count:5`, only the first five unique cities with the most documents in the search results are included in the facet results.
296
+
*`&facet=city,count:5` specifies that only the first five cities found in the top ranked results are returned as a facet result. Consider a sample query with a search term of "airport" and 32 matches. If the query specifies `&facet=city,count:5`, only the first five unique cities with the most documents in the search results are included in the facet results.
297
297
298
298
Notice the distinction between facet results and search results. Search results are all the documents that match the query. Facet results are the matches for each facet value. In the example, search results include City names that are not in the facet classification list (5 in our example). Results that are filtered out through faceted navigation become visible when you clear facets, or choose other facets besides City.
299
299
@@ -305,11 +305,11 @@ Notice the distinction between facet results and search results. Search results
305
305
*`&facet=City,count:12`<br/>
306
306
In a facet query, you can set count to a value. The default is 10, but you can set it higher or lower. Setting `count:12` gets the top 12 matches in facet results by document count.
307
307
* "`@odata.count`"<br/>
308
-
In the query response, this value indicates the number of matching items in the search results. On average, it’s larger than the sum of all facet results combined, due to the presence of items that match the search term, but have no facet value matches.
308
+
In the query response, this value indicates the number of matching items in the search results. On average, it's larger than the sum of all facet results combined, due to the presence of items that match the search term, but have no facet value matches.
309
309
310
310
**Get counts in facet results**
311
311
312
-
When you add a filter to a faceted query, you might want to retain the facet statement (for example, `facet=Rating&$filter=Rating ge 4`). Technically, facet=Rating isn’t needed, but keeping it returns the counts of facet values for ratings 4 and higher. For example, if you click "4" and the query includes a filter for greater or equal to "4", counts are returned for each rating that is 4 and higher.
312
+
When you add a filter to a faceted query, you might want to retain the facet statement (for example, `facet=Rating&$filter=Rating ge 4`). Technically, facet=Rating isn't needed, but keeping it returns the counts of facet values for ratings 4 and higher. For example, if you click "4" and the query includes a filter for greater or equal to "4", counts are returned for each rating that is 4 and higher.
313
313
314
314
**Make sure you get accurate facet counts**
315
315
@@ -329,7 +329,7 @@ Labels are typically defined in the HTML or form (`index.cshtml` in the sample a
329
329
## Filter based on a range
330
330
Faceting over ranges of values is a common search application requirement. Ranges are supported for numeric data and DateTime values. You can read more about each approach in [Search Documents (Azure Cognitive Search API)](https://docs.microsoft.com/rest/api/searchservice/Search-Documents).
331
331
332
-
Azure Cognitive Search simplifies range construction by providing two approaches for computing a range. For both approaches, Azure Cognitive Search creates the appropriate ranges given the inputs you’ve provided. For instance, if you specify range values of 10|20|30, it automatically creates ranges of 0-10, 10-20, 20-30. Your application can optionally remove any intervals that are empty.
332
+
Azure Cognitive Search simplifies range construction by providing two approaches for computing a range. For both approaches, Azure Cognitive Search creates the appropriate ranges given the inputs you've provided. For instance, if you specify range values of 10|20|30, it automatically creates ranges of 0-10, 10-20, 20-30. Your application can optionally remove any intervals that are empty.
333
333
334
334
**Approach 1: Use the interval parameter**
335
335
To set price facets in $10 increments, you would specify: `&facet=price,interval:10`
@@ -353,7 +353,7 @@ To filter documents based on a range you select, you can use the `"ge"` and `"lt
353
353
<aname="geofacets"></a>
354
354
355
355
## Filter based on distance
356
-
It’s common to see filters that help you choose a store, restaurant, or destination based on its proximity to your current location. While this type of filter might look like faceted navigation, it’s just a filter. We mention it here for those of you who are specifically looking for implementation advice for that particular design problem.
356
+
It's common to see filters that help you choose a store, restaurant, or destination based on its proximity to your current location. While this type of filter might look like faceted navigation, it's just a filter. We mention it here for those of you who are specifically looking for implementation advice for that particular design problem.
357
357
358
358
There are two Geospatial functions in Azure Cognitive Search, **geo.distance** and **geo.intersects**.
359
359
@@ -367,7 +367,7 @@ You can find filter examples in [OData expression syntax (Azure Cognitive Search
367
367
## Try the demo
368
368
The Azure Cognitive Search Job Portal Demo contains the examples referenced in this article.
369
369
370
-
- See and test the working demo online at [Azure Cognitive Search Job Portal Demo](https://azjobsdemo.azurewebsites.net/).
370
+
- See and test the working demo online at [Azure Cognitive Search Job Portal Demo](https://aka.ms/azjobsdemo).
371
371
372
372
- Download the code from the [Azure-Samples repo on GitHub](https://github.com/Azure-Samples/search-dotnet-asp-net-mvc-jobs).
Copy file name to clipboardExpand all lines: articles/search/search-pagination-page-layout.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ To quickly generate a search page for your client, explore these options:
21
21
+ Use the [application generator](search-create-app-portal.md) in the portal to create an HTML page with a search bar, faceted navigation, and results area.
22
22
+ Follow the [Create your first app in C#](tutorial-csharp-create-first-app.md) tutorial to create a functional client.
23
23
24
-
Several code samples include a web front-end interface, which you can find here: [New York City Jobs demo app](https://azjobsdemo.azurewebsites.net/), [JavaScript sample code with a live demo site](https://github.com/liamca/azure-search-javascript-samples), and [CognitiveSearchFrontEnd](https://github.com/LuisCabrer/CognitiveSearchFrontEnd).
24
+
Several code samples include a web front-end interface, which you can find here: [New York City Jobs demo app](https://aka.ms/azjobsdemo), [JavaScript sample code with a live demo site](https://github.com/liamca/azure-search-javascript-samples), and [CognitiveSearchFrontEnd](https://github.com/LuisCabrer/CognitiveSearchFrontEnd).
25
25
26
26
> [!NOTE]
27
27
> A valid request includes a number of elements, such as a service URL and path, HTTP verb, `api-version`, and so on. For brevity, we trimmed the examples to highlight just the syntax that is relevant to pagination. For more information about request syntax, see [Azure Cognitive Search REST APIs](https://docs.microsoft.com/rest/api/searchservice).
0 commit comments