Azure AI Search Solution: Apply Filtering and Sorting
Apply Filtering and Sorting
Users frequently like to
filter and order query results according to field values in search solutions.
Both of these features are supported by Azure AI Search via the search query
API.
Filtering Results
You can apply filters to
queries in two ways:
- By including filter criteria in a simple search expression.
- By providing an OData filter expression as a $filter parameter with a full syntax search expression.
You can apply a filter to
any filterable field in the index.
Filtering With Facets
When presenting users
with filtering criteria based on field values in a result set, facets are a
helpful tool. They function best when a field contains a limited number of
discrete values that can be shown in the user interface as options or links.
In order to use facets,
you must first define the facetable fields for which you wish to extract the
potential values.
Sorting Results
The query process's
relevancy score is used by default to rank the results, with the highest
scoring matches appearing first. Nevertheless, by adding an OData orderby
option that identifies one or more sortable fields and a sort order (asc or
desc), you can override this order.
Enhance Index
You may create an
efficient search solution with a simple index and a client that can input
queries and show results. Nonetheless, Azure AI Search offers a number of
methods for improving an index to give users a better experience.
Search-as-you-type
To make it easier for
users to obtain relevant results, you can enable two types of
search-as-you-type experiences by adding a suggester to an index:
- Suggestions -
retrieve and display a list of suggested results as the user types into the
search box, without needing to submit the search query.
- Autocomplete -
complete partially typed search terms based on values in index fields.
To implement one or both
of these capabilities, create or update an index, defining a suggester for one
or more fields.
You can utilize the
suggestion and autocomplete REST API endpoints or the .NET
DocumentsOperationsExtensions after adding a suggester.Make suggestions and
record operations extensions.A list of recommended results or autocompleted
terms to be displayed in the user interface can be obtained by submitting a
partial search phrase using autocomplete methods.
Custom Scoring and Result
Boosting
By default, a relevance
score derived from the term frequency/inverse-document-frequency (TF/IDF)
method is used to order search results.
By creating a scoring
profile that assigns a weighting value to particular fields, basically raising
the search score for documents when the search term appears in those fields, you
may alter how this score is determined.
Additionally, you can
boost results based on field values, for example, increasing the relevancy
score for documents based on how recently they were modified or their file
size. After you have defined a scoring profile, you can specify its use in an
individual search, or you can modify an index definition so that it uses your
custom scoring profile by default.
Synonyms
There are frequently
several ways to refer to the same thing. For example, any of the following
terms may be used by someone looking for information about the United Kingdom:
- United Kingdom
- UK
- Great Britain
- GB
You can create synonym
maps that connect related terms to assist people in finding the information
they require. When a user searches for a specific phrase, documents with fields
containing the term or any of its synonyms will appear in the results. You can
then apply those synonym mappings to individual fields in an index.
Conclusion
We have successfully
learnt about applying filtering and sorting.
Comments
Post a Comment