Skip to content

Commit 709dcbc

Browse files
committed
tip
1 parent 784f4e0 commit 709dcbc

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

articles/search/index-add-scoring-profiles.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,22 @@ POST /indexes/hotels/docs&api-version=2024-07-01
8585

8686
This query searches on the term "inn" and passes in the current location. Notice that this query includes other parameters, such as scoringParameter. Query parameters, including "scoringParameter", are described in [Search Documents (REST API)](/rest/api/searchservice/documents/search-post).
8787

88-
See the [Extended example](#bkmk_ex) to review a more detailed example of a scoring profile.
89-
90-
<a name=what-is-default-scoring></a>
88+
See the [Extended example](#extended-example) to review a more detailed example of a scoring profile.
9189

9290
## How search scoring works in Azure AI Search
9391

9492
Scoring profiles supplement the default scoring algorithm by boosting the scores of matches that meet the profile's criteria. Scoring functions apply to keyword search, pure vector queries, and on hybrid queries. When you use scoring profiles, all queries regardless of type are ranked using the [Reciprocal Ranking Function (RRF)](hybrid-search-ranking.md) algorithm, including standalone text and vector queries. Scoring functions directly affect the final ranking of all documents post-RRF-ranking.
9593

9694
:::image type="content" source="media/scoring-profiles/scoring-over-ranked-results.png" alt-text="Diagram showing which fields have a scoring profile and when ranking occurs.":::
9795

98-
You can use the [featuresMode (preview)](index-similarity-and-scoring.md#featuresmode-parameter-preview) parameter to request extra scoring details with the search results (including the field level scores).
96+
> [!TIP]
97+
> You can use the [featuresMode (preview)](index-similarity-and-scoring.md#featuresmode-parameter-preview) parameter to request extra scoring details with the search results (including the field level scores).
9998
10099
## Add a scoring profile to a search index
101100

102101
1. Start with an [index definition](/rest/api/searchservice/indexes/create). You can add and update scoring profiles on an existing index without having to rebuild it. Use an [Create or Update Index](/rest/api/searchservice/indexes/create-or-update) request to post a revision.
103102

104-
1. Paste in the [template](#bkmk_template) provided in this article.
103+
1. Paste in the [template](#template) provided in this article.
105104

106105
1. Provide a name that adheres to [naming conventions](/rest/api/searchservice/naming-rules).
107106

@@ -113,8 +112,6 @@ Scoring profiles can be defined in Azure portal as shown in the following screen
113112

114113
:::image type="content" source="media/scoring-profiles/portal-add-scoring-profile-small.png" alt-text="Add scoring profiles page" lightbox="media/scoring-profiles/portal-add-scoring-profile.png" border="true":::
115114

116-
<a name="weighted-fields"></a>
117-
118115
## Use weighted fields
119116

120117
Use weighted fields when field context is important and queries include searchable string fields. For example, if a query includes the term "airport", you might want "airport" in the Description field to have more weight than in the HotelName.
@@ -136,15 +133,13 @@ Weighted fields are name-value pairs composed of a searchable field and a positi
136133
]
137134
```
138135

139-
<a name="functions"></a>
140-
141136
## Use functions
142137

143138
Use functions when simple relative weights are insufficient or don't apply, as is the case of distance and freshness, which are calculations over numeric data. You can specify multiple functions per scoring profile. For more information about the EDM data types used in Azure AI Search, see [Supported data types](/rest/api/searchservice/supported-data-types).
144139

145140
| Function | Description | Use cases |
146141
|-|-|
147-
| freshness | Boosts by values in a datetime field (`Edm.DateTimeOffset`). This function has a "boostingDuration" attribute so that you can specify a value representing a timespan over which boosting occurs. | Use this function to boost a match having a more recent date. You can also rank items like calendar events with future dates such that items closer to the present can be ranked higher than items further in the future. One end of the range is fixed to the current time. To boost a range of times in the past, use a positive boostingDuration. To boost a range of times in the future, use a negative boostingDuration. The [interpolation](#set-interpolations) parameter sets the slope. |
142+
| freshness | Boosts by values in a datetime field (`Edm.DateTimeOffset`). This function has a "boostingDuration" attribute so that you can specify a value representing a timespan over which boosting occurs. | Use this function to boost a match having a more recent date. You can also rank items like calendar events with future dates such that items closer to the present can be ranked higher than items further in the future. One end of the range is fixed to the current time. To boost a range of times in the past, use a positive boostingDuration. To boost a range of times in the future, use a negative boostingDuration. The [interpolation](#set-interpolations) parameter sets the slope. For more information, see [set boostingDuration](#set-boostingduration-for-freshness-function). |
148143
| magnitude | The magnitude scoring function is used to alter rankings based on the range of values for a numeric field. The value must be an integer or floating-point number. For star ratings of 1 through 4, this would be 1. For margins over 50%, this would be 50. This function can only be used with `Edm.Double` and `Edm.Int` fields. For the magnitude function, you can reverse the range, high to low, if you want the inverse pattern (for example, to boost lower-priced items more than higher-priced items). Given a range of prices from $100 to $1, you would set "boostingRangeStart" at 100 and "boostingRangeEnd" at 1 to boost the lower-priced items. | Scenarios that call for this function include boosting by profit margin, highest price, lowest price, or a count of downloads. Common usage examples of this are: </br></br>"Star ratings:" Alter the scoring based on the value within the "Star Rating" field. When two items are relevant, the item with the higher rating will be displayed first. </br>"Margin:" When two documents are relevant, a retailer might wish to boost documents that have higher margins first. </br>"Clickthrough counts:" For applications that track clickthrough actions to products or pages, you could use magnitude to boost items that tend to get the most traffic. </br>"Download counts:" For applications that track downloads, the magnitude function lets you boost items that have the most downloads. |
149144
| distance | Boosts by proximity or geographic location. This function can only be used with `Edm.GeographyPoint` fields. | Use for "find near me" scenarios. |
150145
| tag | Boosts by tags that are common to both search documents and query strings. Tags are provided in a "tagsParameter". This function can only be used with search fields of type `Edm.String` and `Collection(Edm.String)`. | Use when you have tag fields. If a given tag within the list is itself a comma-delimited list, you can [use a text normalizer](search-normalizers.md) on the field to strip out the commas at query time (map the comma character to a space). This approach will "flatten" the list so that all terms are a single, long string of comma-delimited terms. |
@@ -156,8 +151,6 @@ Use functions when simple relative weights are insufficient or don't apply, as i
156151
+ Functions can't include null or empty values.
157152
+ Functions can only have a single field per function definition. To use magnitude twice in the same profile, provide two definitions magnitude, one for each field.
158153

159-
<a name="bkmk_template"></a>
160-
161154
## Template
162155

163156
This section shows the syntax and template for scoring profiles. For a description of properties, see the [REST API reference](/rest/api/searchservice/indexes/create?view=rest-searchservice-2024-07-01&preserve-view=true#scoringfunctionaggregation).
@@ -209,9 +202,7 @@ Use functions when simple relative weights are insufficient or don't apply, as i
209202
}
210203
],
211204
"defaultScoringProfile": (optional) "...",
212-
```
213-
214-
<a name="bkmk_interpolation"></a>
205+
```
215206

216207
## Set interpolations
217208

@@ -226,9 +217,7 @@ Interpolations set the shape of the slope used for scoring. Because scoring is h
226217

227218
![Constant, linear, quadratic, log10 lines on graph](media/scoring-profiles/azuresearch_scorefunctioninterpolationgrapht.png "AzureSearch_ScoreFunctionInterpolationGrapht")
228219

229-
<a name="bkmk_boostdur"></a>
230-
231-
## Set boostingDuration
220+
## Set boostingDuration for freshness function
232221

233222
`boostingDuration` is an attribute of the `freshness` function. You use it to set an expiration period after which boosting will stop for a particular document. For example, to boost a product line or brand for a 10-day promotional period, you would specify the 10-day period as "P10D" for those documents.
234223

@@ -243,9 +232,7 @@ The following table provides several examples.
243232
|15 minutes|"PT15M"|
244233
|30 days, 5 hours, 10 minutes, and 6.334 seconds|"P30DT5H10M6.334S"|
245234

246-
For more examples, see [XML Schema: Datatypes (W3.org web site)](https://www.w3.org/TR/xmlschema11-2/#dayTimeDuration).
247-
248-
<a name="bkmk_ex"></a>
235+
For more examples, see [XML Schema: Datatypes (W3.org web site)](https://www.w3.org/TR/xmlschema11-2/#dayTimeDuration).
249236

250237
## Extended example
251238

articles/search/query-lucene-syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Proximity searches are used to find terms that are near each other in a document
130130

131131
Term boosting refers to ranking a document higher if it contains the boosted term, relative to documents that don't contain the term. This differs from scoring profiles in that scoring profiles boost certain fields, rather than specific terms.
132132

133-
The following example helps illustrate the differences. Suppose that there's a scoring profile that boosts matches in a certain field, say *genre* in the [musicstoreindex example](index-add-scoring-profiles.md#bkmk_ex). Term boosting could be used to further boost certain search terms higher than others. For example, `rock^2 electronic` boosts documents that contain the search terms in the genre field higher than other searchable fields in the index. Further, documents that contain the search term *rock* are ranked higher than the other search term *electronic* as a result of the term boost value (2).
133+
The following example helps illustrate the differences. Suppose that there's a scoring profile that boosts matches in a certain field, say *genre* in the [musicstoreindex example](index-add-scoring-profiles.md#extended-example). Term boosting could be used to further boost certain search terms higher than others. For example, `rock^2 electronic` boosts documents that contain the search terms in the genre field higher than other searchable fields in the index. Further, documents that contain the search term *rock* are ranked higher than the other search term *electronic* as a result of the term boost value (2).
134134

135135
To boost a term, use the caret, `^`, symbol with a boost factor (a number) at the end of the term you're searching. You can also boost phrases. The higher the boost factor, the more relevant the term is relative to other search terms. By default, the boost factor is 1. Although the boost factor must be positive, it can be less than 1 (for example, 0.20).
136136

0 commit comments

Comments
 (0)