- [Instructor] I highly recommend visiting this link, which is azjobsdemo.azurewebsites.net. It's created by the Azure Search team, and you can come in here and practice some of these features. This one is an auto complete. For example, if you have to search for project manager, it brings up some of these project managers and then when you click for it, you should technically get some results.
Maybe you can just enter on project manager and look at the results that are coming back from the data set. We all have seen typeaheads and autocompletes, so that's not something that's very important, however, if you do not know what a facet is, maybe you might want to just consider looking at the filter results here. So what you could do, is you could click Administrative Assistant. You can see that the current filter has that assistant selected. And then you can see we have Internal five jobs, and External three, and then the minimum salary is here.
But if we were to remove that and just pick something else, that's a facet that gets selected. And then the rest of the data changes according to that particular facet. So let's pick External in this case. So you'll see there are three available jobs, and we've selected two facets. So these two facets now become the filters for the next request, or the next search request. Back to Visual Studio, quite interestingly, Azure Search simplifies faceting quite a bit.
All we need to do is use something like search parameters. Let's take a query, we can get it off some of this code. We can have a query client on the same exact index we've been working with. Remove some of this code, and then say SearchParameters. Call it SearchParameters equals new SearchParameters, and say Facets equals new List of string.
And we can do faceting on balance, which happens to be double and age, which happens to be an integer. And then we can do a query. Results equals indexClient.documents. Search of type Account. And then Say CA comma searchParameters.
That's all we need. Now, it's not working magically. If you remember, what we've done originally is add IsFacetable on Age, and then IsFacetable on Balance two. So if I were to go back here, I should be able to get the data back in terms of facets. I'm going to put a break one right here. So now before we run this example, you want to make sure that we remove this code, 'cause otherwise it's going to delete our index and then re-index it.
And the next thing you can do is also remove ImportDocuments 'cause there's no need to import any other document. Since we're not really changing anything here, it's completely okay to leave this code as it is, 'cause it's not going to key out or update anything. And then we can press F5. Look at the results. We get two facets, but at the same time we get 17 results. Now, if we were to go into results, you can see that we have a document here, and the document has State California, and then we can also look into more documents.
And all of these documents will have the State California. Which is great. But then we look at the facets. We want the facets to do this for us. So for example, if you look at the Key which is balance, I get 10 records for the key balance, and then I get 10 records for the key age. Which is exactly what I'm looking for. Now it makes my life so much easier, because I have different kind of values.
So in this case we have Count which is one, and the value happens to be 6087. But imagine, our data was a little different. If our data had a category, which was let's say hundred, and we had five records with hundred, we would have got Count five, and then we have had the value hundred. Which is exactly where faceting comes into place. And we can still use this particular structure of values to create something more meaningful for us, but the benefit of facets as you notice, is structuring that data for us in some kind of category format that we might end up using on the UI.
- Querying and indexing
- Creating a search service
- Using APIs during searching
- Importing JSON data
- Handling synonyms
- Working with suggestors and facets