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
Copy file name to clipboardExpand all lines: articles/search/index-add-scoring-profiles.md
+64-19Lines changed: 64 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ms.service: azure-ai-search
10
10
ms.custom:
11
11
- ignite-2023
12
12
ms.topic: how-to
13
-
ms.date: 07/23/2025
13
+
ms.date: 07/25/2025
14
14
---
15
15
16
16
# Add scoring profiles to boost search scores
@@ -27,7 +27,7 @@ You can add a scoring profile to an index by editing its JSON definition in the
27
27
28
28
## Prerequisites
29
29
30
-
+ A search index with text or numeric fields.
30
+
+ A search index with text or numeric (nonvector) fields.
31
31
32
32
## Rules for scoring profiles
33
33
@@ -47,7 +47,7 @@ You can use [semantic ranker](semantic-how-to-query-request.md) with scoring pro
47
47
48
48
A scoring profile is defined in an index schema. It consists of weighted fields, functions, and parameters.
49
49
50
-
The following definition shows a simple profile named "geo". This example boosts results that have the search term in the hotelName field. It also uses the `distance` function to favor results that are within 10 kilometers of the current location. If someone searches on the term 'inn', and 'inn' happens to be part of the hotel name, documents that include hotels with 'inn' within a 10kilometer radius of the current location appear higher in the search results.
50
+
The following definition shows a simple profile named "geo". This example boosts results that have the search term in the hotelName field. It also uses the `distance` function to favor results that are within 10 kilometers of the current location. If someone searches on the term 'inn', and 'inn' happens to be part of the hotel name, documents that include hotels with 'inn' within a 10-kilometer radius of the current location appear higher in the search results.
51
51
52
52
```json
53
53
"scoringProfiles": [
@@ -87,7 +87,7 @@ POST /indexes/hotels/docs&api-version=2024-07-01
87
87
88
88
Query parameters, including `scoringParameters`, are described in [Search Documents (REST API)](/rest/api/searchservice/documents/search-post).
89
89
90
-
For more scenarios, see the [example](#example-of-a-scoring-profile) in this article.
90
+
For more scenarios, see the examples for [freshness and distance](#example-boosting-by-freshness-or-distance) and [weighted text and functions](#example-boosting-by-weighted-text-and-functions) in this article.
91
91
92
92
## Add a scoring profile to a search index
93
93
@@ -160,7 +160,7 @@ Scoring profiles can be defined in the Azure portal as shown in the following sc
160
160
161
161
## Use text-weighted fields
162
162
163
-
Use text-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 HotelName field than the Description field.
163
+
Use text-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 HotelName field rather than the Description field.
164
164
165
165
Weighted fields are name-value pairs composed of a `searchable` field and a positive number that is used as a multiplier. If the original field score of HotelName is 3, the boosted score for that field becomes 6, contributing to a higher overall score for the parent document itself.
166
166
@@ -186,8 +186,8 @@ Use functions when simple relative weights are insufficient or don't apply, as i
186
186
|-|-|
187
187
| distance | Boost by proximity or geographic location. This function can only be used with `Edm.GeographyPoint` fields. | Use for "find near me" scenarios. |
188
188
| freshness | Boost by values in a datetime field (`Edm.DateTimeOffset`). [Set boostingDuration](#set-boostingduration-for-freshness-function) to specify a value representing a timespan over which boosting occurs. | Use when you want to boost by newer or older dates. 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. |
189
-
| magnitude | 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. | Use when you want to boost by profit margin, ratings, clickthrough counts, number of downloads, highest price, lowest price, or a count of downloads. When two items are relevant, the item with the higher rating will be displayed first. |
190
-
| tag | Boost 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. |
189
+
| magnitude | Magnitude is the computed distance between the document’s value (such as a date or location) and the reference point (such as "now" or a target location). It’s the input to the scoring function and determines how much boost is applied. 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. | Use when you want to boost by profit margin, ratings, clickthrough counts, number of downloads, highest price, lowest price, or a count of downloads. When two items are relevant, the item with the higher rating is displayed first. |
190
+
| tag | Boost 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 "flattens" the list so that all terms are a single, long string of comma-delimited terms. |
191
191
192
192
### Rules for using functions
193
193
@@ -198,20 +198,22 @@ Use functions when simple relative weights are insufficient or don't apply, as i
198
198
199
199
### Set interpolations
200
200
201
-
Interpolations set the shape of the slope used for scoring. Because scoring is high to low, the slope is always decreasing, but the interpolation determines the curve of the downward slope. The following interpolations can be used:
201
+
Interpolations set the shape of the slope used for boosting freshness and distance. Because scoring is high to low, the slope is always decreasing, but the interpolation determines the curve of the downward slope and how aggressively the boost score changes as document dates get older. The following interpolations can be used:
202
202
203
203
| Interpolation | Description |
204
204
|-|-|
205
-
|`linear`|For items that are within the max and min range, boosting is applied in a constantly decreasing amount. Linear is the default interpolation for a scoring profile.|
206
-
|`constant`|For items that are within the start and ending range, a constant boost is applied to the rank results.|
207
-
|`quadratic`|In comparison to a linear interpolation that has a constantly decreasing boost, Quadratic initially decreases at smaller pace and then as it approaches the end range, it decreases at a much higher interval. This interpolation option isn't allowed in tag scoring functions.|
208
-
|`logarithmic`|In comparison to a linear interpolation that has a constantly decreasing boost, logarithmic initially decreases at higher pace and then as it approaches the end range, it decreases at a much smaller interval. This interpolation option isn't allowed in tag scoring functions.|
205
+
|`linear`|Penalizes older documents proportionally. Good for gradual decay in relevance. Linear is the default interpolation for a scoring profile.|
206
+
|`constant`|Applies the same negative boost to all documents within the range. Use this when you want a flat penalty regardless of age.|
207
+
|`quadratic`|Penalizes older documents increasingly more as they age. Use this when you want to strongly favor the most recent documents and sharply demote older ones. This interpolation option isn't allowed in the tag scoring function.|
208
+
|`logarithmic`|Penalizes older documents more sharply at first, then tapers off. Ideal when you want strong preference for very recent content but less sensitivity as documents age. This interpolation option isn't allowed in the tag scoring function.|
209
209
210
-

210
+

211
+
212
+
:::image type="content" source="media/scoring-profiles/interpolation-graph.png" alt-text="Diagram of slope shapes for constant, linear, logarithmic, and quadratic interpolations over a 365 day range":::
211
213
212
214
### Set boostingDuration for freshness function
213
215
214
-
`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.
216
+
`boostingDuration` is an attribute of the `freshness` function. You use it to set an expiration period after which boosting stops 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.
215
217
216
218
`boostingDuration` must be formatted as an XSD "dayTimeDuration" value (a restricted subset of an ISO 8601 duration value). The pattern for this is: "P[nD][T[nH][nM][nS]]".
217
219
@@ -222,18 +224,61 @@ The following table provides several examples.
222
224
|1 day|"P1D"|
223
225
|2 days and 12 hours|"P2DT12H"|
224
226
|15 minutes|"PT15M"|
225
-
|30 days, 5 hours, 10 minutes, and 6.334 seconds|"P30DT5H10M6.334S"|
227
+
|30 days, 5 hours, 10 minutes, and 6.334 seconds|"P30DT5H10M6.334S"|
228
+
|1 year | "365D" |
226
229
227
230
For more examples, see [XML Schema: Datatypes (W3.org web site)](https://www.w3.org/TR/xmlschema11-2/#dayTimeDuration).
228
231
229
-
## Example of a scoring profile
232
+
## Example: boosting by freshness or distance
233
+
234
+
In Azure AI Search, freshness scoring converts date and values into a numeric magnitude—a single number representing how far a document's date is from the current time. The older the date, the larger the magnitude. This leads to a counter-intuitive behavior: more recent documents have smaller magnitudes, which means that positive boosting factors favor older documents unless you explicitly invert the boost direction.
235
+
236
+
This same logic applies to distance boosting, where farther locations yield larger magnitudes.
237
+
238
+
To boost by freshness or distance, use negative boosting values to prioritize newer dates or closer locations. Inverting the boost direction through a negative boosting factor penalizes larger magnitudes (older dates), effectively boosting more recent ones. For example, assume a boosting function like `b * (1 - x)` (where `x` is the normalized magnitude from 0 to 1) that gives higher scores to smaller magnitudes (that is, newer dates).
239
+
240
+
The shape of the boost curve (constant, linear, logarithmic, quadratic) affects how aggressively scores change across the range. With a negative factor, the curve’s behavior flips—for example, a quadratic curve tapers off more slowly for older dates, while a logarithmic curve shifts more sharply at the far end.
241
+
242
+
Here's an example scoring profile that demonstrates how to address counter-intuitive freshness scoring using negative boosting and explains how magnitude works in this context.
243
+
244
+
```json
245
+
246
+
"scoringProfiles": [
247
+
{
248
+
"name": "freshnessBoost",
249
+
"text": {
250
+
"weights": {
251
+
"content": 1.0
252
+
}
253
+
},
254
+
"functions": [
255
+
{
256
+
"type": "freshness",
257
+
"fieldName": "lastUpdated",
258
+
"boost": -2.0,
259
+
"interpolation": "quadratic",
260
+
"parameters": {
261
+
"boostingDuration": "365D"
262
+
}
263
+
}
264
+
]
265
+
}
266
+
]
267
+
```
268
+
269
+
+`"fieldName": "lastUpdated"` is the datetime field used to calculate freshness.
270
+
+`"boost": -2.0` is a negative boosting factor, which inverts the default behavior. Since older dates have larger magnitudes, this penalizes them and boosts newer documents.
271
+
+`"interpolation": "quadratic"` means the boost effect is stronger for documents closer to the current date and tapers off more sharply for older ones.
272
+
+`"boostingDuration": "365D"` defines the time window over which freshness is evaluated.
273
+
274
+
## Example: boosting by weighted text and functions
230
275
231
276
> [!TIP]
232
277
> See this [blog post](https://farzzy.hashnode.dev/enhance-azure-ai-search-document-boosting) and [notebook](https://github.com/farzad528/azure-ai-search-python-playground/blob/main/azure-ai-search-document-boosting.ipynb) for a demonstration of using scoring profiles and document boosting in vector and generative AI scenarios.
233
278
234
-
The following example shows the schema of an index with two scoring profiles (`boostGenre`, `newAndHighlyRated`). Any query against this index that includes either profile as a query parameter will use the profile to score the result set.
279
+
The following example shows the schema of an index with two scoring profiles (`boostGenre`, `newAndHighlyRated`). Any query against this index that includes either profile as a query parameter uses the profile to score the result set.
235
280
236
-
The `boostGenre` profile uses weighted text fields, boosting matches found in albumTitle, genre, and artistName fields. The fields are boosted 1.5, 5, and 2 respectively. Why is genre boosted so much higher than the others? If search is conducted over data that is somewhat homogeneous (as is the case with 'genre' in the musicstoreindex), you might need a larger variance in the relative weights. For example, in the musicstoreindex, 'rock' appears as both a genre and in identically phrased genre descriptions. If you want genre to outweigh genre description, the genre field will need a much higher relative weight.
281
+
The `boostGenre` profile uses weighted text fields, boosting matches found in albumTitle, genre, and artistName fields. The fields are boosted 1.5, 5, and 2 respectively. Why is genre boosted so much higher than the others? If search is conducted over data that is somewhat homogeneous (as is the case with 'genre' in the musicstoreindex), you might need a larger variance in the relative weights. For example, in the musicstoreindex, 'rock' appears as both a genre and in identically phrased genre descriptions. If you want genre to outweigh genre description, the genre field needs a much higher relative weight.
237
282
238
283
```json
239
284
{
@@ -270,7 +315,7 @@ The `boostGenre` profile uses weighted text fields, boosting matches found in al
0 commit comments