Join Chander Dhall for an in-depth discussion in this video Searching API examples, part of Azure Search for Developers.
- [Instructor] Here are some examples when we are searching an API. So we can say /docs? and then the query string is search equals whatever your search text is. The next one could be search with a filter, and in this case we're saying Austin, which is a city in Texas, and then we're saying filter the state and state equals Texas. So this is more like an old data way of searching things. And number three is where we're also doing sorting, paging.
At the same time we're also doing field selection. So the first part is search, which is the same as Austin, and then we have order by state, because even though I'm searching for Austin, I still want my data to be ordered by state. I could have Austin in multiple states, what if I have the same city in multiple states? Or it doesn't even matter. Technically, this search could be not just for that particular field, which is city, it could also be someone's first name or even last name. Well the next one, you can see is ordering by state, D-E-S-C, which means show me the states, but in descending order, start from Z, go all the way to A.
And now we have top, which is 20, which we discussed, this is pagination. And then the last one, and the most important one, is select. As you can see, we're saying select name and email only. So if you had a big object, that we decided to index, we only want the two fields, in this case, name and email, and we don't want the entire object. This is very good because we want our payload always to be as small as possible.
Number four is facets, and as we discussed earlier, in this case all we are saying is categorize my data based on state and city. And state and city are not values. These are keys for those particular fields which happen to be state and city. And number five, we're saying highlight the name. So we had a property call name and our search keyword was cazton. We want that name property to be highlighted.
- Querying and indexing
- Creating a search service
- Using APIs during searching
- Importing JSON data
- Handling synonyms
- Working with suggestors and facets