将计分概要文件添加到 Azure 认知搜索索引Add scoring profiles to an Azure Cognitive Search index

计分对排序结果集中的每项计算搜索分数。Scoring computes a search score for each item in a rank ordered result set. 搜索结果集中的每项都分配到一个搜索分数,并从高到低排名。Every item in a search result set is assigned a search score, then ranked highest to lowest.

Azure 认知搜索使用默认计分计算初始分数,但可以通过“计分概要文件”自定义计算。Azure Cognitive Search uses default scoring to compute an initial score, but you can customize the calculation through a scoring profile. 借助计分概要文件,可以更好地控制搜索结果中的项排名。Scoring profiles give you greater control over the ranking of items in search results. 例如,建议根据创收能力提升项、提升新项或提升库存时间太长的项。For example, you might want to boost items based on their revenue potential, promote newer items, or perhaps boost items that have been in inventory too long.

计分概要文件定义Scoring profile definitions

计分概要文件属于索引定义的一部分,由加权字段、函数和参数组成。A scoring profile is part of the index definition, composed of weighted fields, functions, and parameters.

若要概览计分概要文件,请参阅下面的示例,其中展示了名为“geo”的简单概要文件。To give you an idea of what a scoring profile looks like, the following example shows a simple profile named 'geo'. 此文件用于提升在“hotelName”字段中具有搜索词的项。This one boosts items that have the search term in the hotelName field. 它还使用 distance 函数优先提升在当前位置十公里范围内的项。It also uses the distance function to favor items that are within ten kilometers of the current location. 如果有人搜索“inn”一词,而“inn”恰好是酒店名称的一部分,包含当前位置 10 公里范围内带有“inn”的酒店的文档会在搜索结果中的较高位置出现。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 KM radius of the current location will appear higher in the search results.

"scoringProfiles": [
  {  
    "name":"geo",
    "text": {  
      "weights": {  
        "hotelName": 5
      }                              
    },
    "functions": [
      {  
        "type": "distance",
        "boost": 5,
        "fieldName": "location",
        "interpolation": "logarithmic",
        "distance": {
          "referencePointParameter": "currentLocation",
          "boostingDistance": 10
        }                        
      }                                      
    ]                     
  }            
]

若要使用此计分概要文件,查询要表述为对查询字符串指定此概要文件。To use this scoring profile, your query is formulated to specify the profile on the query string. 在下面的查询中,请注意请求中的查询参数 scoringProfile=geoIn the query below, notice the query parameter scoringProfile=geo in the request.

GET /indexes/hotels/docs?search=inn&scoringProfile=geo&scoringParameter=currentLocation--122.123,44.77233&api-version=2020-06-30 

此查询对“inn”一词进行搜索,并在当前位置中传递。This query searches on the term ‘inn’ and passes in the current location. 请注意,此查询包含其他参数,如 scoringParameterNotice that this query includes other parameters, such as scoringParameter. 有关查询参数的信息,请参阅搜索文档(Azure 认知搜索 REST API)Query parameters are described in Search Documents (Azure Cognitive Search REST API).

单击示例查看计分概要文件的更详细示例。Click Example to review a more detailed example of a scoring profile.

什么是默认计分?What is default scoring?

计分对排序结果集中的每项计算搜索分数。Scoring computes a search score for each item in a rank ordered result set. 搜索结果集中的每项都分配到一个搜索分数,并从高到低排名。Every item in a search result set is assigned a search score, then ranked highest to lowest. 分数较高的项返回应用程序。Items with the higher scores are returned to the application. 默认返回前 50 个,但可以使用 $top 参数返回较少或较多的项(单个响应中最多 1000 个)。By default, the top 50 are returned, but you can use the $top parameter to return a smaller or larger number of items (up to 1000 in a single response).

根据数据和查询的统计属性计算搜索分数。The search score is computed based on statistical properties of the data and the query. Azure 认知搜索查找包含了查询字符串中搜索词的文档(部分或全部包含,具体取决于 searchMode),优先列出包含该搜索词多个实例的文档。Azure Cognitive Search finds documents that include the search terms in the query string (some or all, depending on searchMode), favoring documents that contain many instances of the search term. 如果搜索词在数据索引中很少见,但在文档中很常见,搜索分数仍升至更高。The search score goes up even higher if the term is rare across the data index, but common within the document. 这种相关性计算方法的基础称为“TF-IDF”(词频-逆文档频率)。The basis for this approach to computing relevance is known as TF-IDF or term frequency-inverse document frequency.

假设没有自定义排序,结果在返回调用应用程序之前按搜索分数排名。Assuming there is no custom sorting, results are then ranked by search score before they are returned to the calling application. 如果 $top 未指定,则返回具有最高搜索分数的 50 项。If $top is not specified, 50 items having the highest search score are returned.

搜索分数值可以在整个结果集中重复。Search score values can be repeated throughout a result set. 例如,可能有 10 个分数为 1.2 的项,20 个分数为 1.0 的项,20 个分数为 0.5 的项。For example, you might have 10 items with a score of 1.2, 20 items with a score of 1.0, and 20 items with a score of 0.5. 当多个命中具有相同的搜索分数时,得分相同项的顺序未定义,并且不稳定。When multiple hits have the same search score, the ordering of same scored items is not defined, and is not stable. 重新运行查询后,可能会看到项移位。Run the query again, and you might see items shift position. 对于具有相同分数的两项,无法保证先显示哪一个。Given two items with an identical score, there is no guarantee which one appears first.

何时添加评分逻辑When to add scoring logic

当默认排名行为不足以满足业务目标时,应创建一个或更多计分概要文件。You should create one or more scoring profiles when the default ranking behavior doesn’t go far enough in meeting your business objectives. 例如,可能会决定搜索相关性应更倾向于新添加的项。For example, you might decide that search relevance should favor newly added items. 同样,可能有一个包含利润率的字段,或其他某些指示营收潜力的字段。Likewise, you might have a field that contains profit margin, or some other field indicating revenue potential. 提升为业务带来益处的命中可能是确定使用计分概要文件的一个重要因素。Boosting hits that bring benefits to your business can be an important factor in deciding to use scoring profiles.

基于相关性的排序也通过计分概要文件实现。Relevancy-based ordering is also implemented through scoring profiles. 请考虑过去使用的可以按价格、日期、评分或相关性排序的搜索结果页。Consider search results pages you’ve used in the past that let you sort by price, date, rating, or relevance. 在 Azure 认知搜索中,计分概要文件驱动“相关性”选项。In Azure Cognitive Search, scoring profiles drive the ‘relevance’ option. 相关性定义由你控制,基于业务目标和希望提供的搜索体验类型断定。The definition of relevance is controlled by you, predicated on business objectives and the type of search experience you want to deliver.

示例Example

如前所述,自定义计分是通过索引模式中定义的一个或多个计分概要文件实现的。As noted earlier, customized scoring is implemented through one or more scoring profiles defined in an index schema.

此示例演示具有两个计分概要文件的索引架构(boostGenrenewAndHighlyRated)。This 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.

{  
  "name": "musicstoreindex",  
  "fields": [  
    { "name": "key", "type": "Edm.String", "key": true },  
    { "name": "albumTitle", "type": "Edm.String" },  
    { "name": "albumUrl", "type": "Edm.String", "filterable": false },  
    { "name": "genre", "type": "Edm.String" },  
    { "name": "genreDescription", "type": "Edm.String", "filterable": false },  
    { "name": "artistName", "type": "Edm.String" },  
    { "name": "orderableOnline", "type": "Edm.Boolean" },  
    { "name": "rating", "type": "Edm.Int32" },  
    { "name": "tags", "type": "Collection(Edm.String)" },  
    { "name": "price", "type": "Edm.Double", "filterable": false },  
    { "name": "margin", "type": "Edm.Int32", "retrievable": false },  
    { "name": "inventory", "type": "Edm.Int32" },  
    { "name": "lastUpdated", "type": "Edm.DateTimeOffset" }  
  ],  
  "scoringProfiles": [  
    {  
      "name": "boostGenre",  
      "text": {  
        "weights": {  
          "albumTitle": 1.5,  
          "genre": 5,  
          "artistName": 2  
        }  
      }  
    },  
    {  
      "name": "newAndHighlyRated",  
      "functions": [  
        {  
          "type": "freshness",  
          "fieldName": "lastUpdated",  
          "boost": 10,  
          "interpolation": "quadratic",  
          "freshness": {  
            "boostingDuration": "P365D"  
          }  
        },  
        {
          "type": "magnitude",  
          "fieldName": "rating",  
          "boost": 10,  
          "interpolation": "linear",  
          "magnitude": {  
            "boostingRangeStart": 1,  
            "boostingRangeEnd": 5,  
            "constantBoostBeyondRange": false  
          }  
        }  
      ]  
    }  
  ],  
  "suggesters": [  
    {  
      "name": "sg",  
      "searchMode": "analyzingInfixMatching",  
      "sourceFields": [ "albumTitle", "artistName" ]  
    }  
  ]   
}  

工作流Workflow

要实现自定义计分行为,请将计分概要文件添加到定义该索引的架构。To implement custom scoring behavior, add a scoring profile to the schema that defines the index. 在一个索引中可以具有最多 100 个计分概要文件(请参阅服务限制),但在任何给定查询中,一次只能指定一个概要文件。You can have up to 100 scoring profiles within an index (see Service Limits), but you can only specify one profile at time in any given query.

从本主题中提供的模板开始。Start with the Template provided in this topic.

提供一个名称。Provide a name. 计分概要文件为可选项,但如果要添加一个概要文件,必须提供名称。Scoring profiles are optional, but if you add one, the name is required. 请务必遵循字段的命名约定(以字母开头,避免使用特殊字符和保留字)。Be sure to follow the naming conventions for fields (starts with a letter, avoids special characters and reserved words). 有关完整列表,请参阅命名规则(Azure 认知搜索)See Naming rules (Azure Cognitive Search) for the complete list.

计分概要文件的主体由加权字段和函数构造而成。The body of the scoring profile is constructed from weighted fields and functions.

权重Weights 指定为字段分配相对权重的名称/值对。Specify name-value pairs that assign a relative weight to a field. 示例中,albumTitle、genre 和 artistName 字段各自提升 1.5、5 和 2。In the Example, the albumTitle, genre, and artistName fields are boosted 1.5, 5, and 2 respectively. genre 为何比其他字段提升更高?Why is genre boosted so much higher than the others? 如果对在某种程度上为同类的数据执行搜索(正如 musicstoreindex 中的“genre”一样),可能需要在相对权重中产生较大差异。If search is conducted over data that is somewhat homogenous (as is the case with 'genre' in the musicstoreindex), you might need a larger variance in the relative weights. 例如,在 musicstoreindex 中,“rock”既作为流派显示,又显示在采用相同组句方式的流派说明中。For example, in the musicstoreindex, ‘rock’ appears as both a genre and in identically phrased genre descriptions. 如果希望流派的权重在流派说明之上,genre 字段将需要更高的相对权重。If you want genre to outweigh genre description, the genre field will need a much higher relative weight.
函数Functions 在特定上下文需要进行额外计算时使用。Used when additional calculations are required for specific contexts. 有效的值为 freshnessmagnitudedistancetagValid values are freshness, magnitude, distance, and tag. 每个函数具有独有的参数。Each function has parameters that are unique to it.

当希望按项目的新旧方式进行提升时,应使用 - freshness- freshness should be used when you want to boost by how new or old an item is. 此函数仅可与 datetime 字段结合使用 (edm.DataTimeOffset)。This function can only be used with datetime fields (edm.DataTimeOffset). 请注意,boostingDuration 属性仅用于 freshness 函数。Notice the boostingDuration attribute is used only with the freshness function.
当希望按数值高低程度提升时,应使用 - magnitude- magnitude should be used when you want to boost based on how high or low a numeric value is. 调用此函数的方案包括按照利润率、最高价格、最低价格或下载次数提升。Scenarios that call for this function include boosting by profit margin, highest price, lowest price, or a count of downloads. 此函数仅可与 double 和 integer 字段结合使用。This function can only be used with double and integer fields.
对于 magnitude 函数,如果想要反转模式(例如,将价格较低项提升至价格较高项之上),可以将范围反转为从高到低。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). 假设价格范围从 100 美元到 1 美元,可以将 boostingRangeStart 设为 100、boostingRangeEnd 设为 1 以提升价格较低的项。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.
当希望按距离或地理位置提升时,应使用 - distance- distance should be used when you want to boost by proximity or geographic location. 此函数仅可与 Edm.GeographyPoint 字段结合使用。This function can only be used with Edm.GeographyPoint fields.
当希望按文档和搜索查询之间共有的标记提升时,应使用 - tag- tag should be used when you want to boost by tags in common between documents and search queries. 此函数仅可与 Edm.StringCollection(Edm.String) 字段结合使用。This function can only be used with Edm.String and Collection(Edm.String) fields.

使用函数的规则Rules for using functions

函数类型(freshnessmagnitudedistancetag 必须小写。Function type (freshness, magnitude, distance), tag must be lower case.

函数不能包含 null 或空值。Functions cannot include null or empty values. 具体而言,如果包含字段名称,则必须将其设置为某值。Specifically, if you include fieldname, you have to set it to something.

函数仅可应用于可筛选字段。Functions can only be applied to filterable fields. 有关可筛选字段的详细信息,请参阅创建索引(Azure 认知搜索 REST API)See Create Index (Azure Cognitive Search REST API) for more information about filterable fields.

函数仅可应用于在索引的字段集合中定义的字段。Functions can only be applied to fields that are defined in the fields collection of an index.

定义索引后,请通过上传索引架构(后跟文档)建立索引。After the index is defined, build the index by uploading the index schema, followed by documents. 有关这些操作的说明,请参阅创建索引(Azure 认知搜索 REST API)添加、更新或删除文档(Azure 认知搜索 REST API)See Create Index (Azure Cognitive Search REST API) and Add, Update or Delete Documents (Azure Cognitive Search REST API) for instructions on these operations. 建立索引后,应获得适用于搜索数据的函数计分概要文件。Once the index is built, you should have a functional scoring profile that works with your search data.

模板Template

本部分演示计分概要文件的语法和模板。This section shows the syntax and template for scoring profiles. 请参阅下一部分的索引属性参考,获取属性的说明。Refer to Index attributes reference in the next section for descriptions of the attributes.

. . .   
"scoringProfiles": [  
  {   
    "name": "name of scoring profile",   
    "text": (optional, only applies to searchable fields) {   
      "weights": {   
        "searchable_field_name": relative_weight_value (positive #'s),   
        ...   
      }   
    },   
    "functions": (optional) [  
      {   
        "type": "magnitude | freshness | distance | tag",   
        "boost": # (positive number used as multiplier for raw score != 1),   
        "fieldName": "...",   
        "interpolation": "constant | linear (default) | quadratic | logarithmic",   

        "magnitude": {
          "boostingRangeStart": #,   
          "boostingRangeEnd": #,   
          "constantBoostBeyondRange": true | false (default)
        }  

        // ( - or -)  

        "freshness": {
          "boostingDuration": "..." (value representing timespan over which boosting occurs)   
        }  

        // ( - or -)  

        "distance": {
          "referencePointParameter": "...", (parameter to be passed in queries to use as reference location)   
          "boostingDistance": # (the distance in kilometers from the reference location where the boosting range ends)   
        }   

        // ( - or -)  

        "tag": {
          "tagsParameter":  "..."(parameter to be passed in queries to specify a list of tags to compare against target field)   
        }
      }
    ],   
    "functionAggregation": (optional, applies only when functions are specified) "sum (default) | average | minimum | maximum | firstMatching"   
  }   
],   
"defaultScoringProfile": (optional) "...",   
. . .  

索引属性参考Index attributes reference

备注

计分函数仅可应用于可筛选的字段。A scoring function can only be applied to fields that are filterable.

属性Attribute 说明Description
name 必需。Required. 这是计分概要文件的名称。This is the name of the scoring profile. 它遵循与字段相同的命名约定。It follows the same naming conventions of a field. 它必须以字母开头,不能包含点、冒号或 @ 符号,并且不能以短语“azureSearch”(区分大小写)开头。It must start with a letter, cannot contain dots, colons or @ symbols, and cannot start with the phrase ‘azureSearch’ (case-sensitive).
text 包含 weights 属性。Contains the weights property.
weights 可选。Optional. 包含多个名称/值对,每个名称/值对指定一个字段名称和相对权重。Contains name-value pairs that each specify a field name and relative weight. 相对权重必须为正整数或浮点数。Relative weight must be a positive integer or floating-point number.

权重用于指示一个可搜索字段相对于另一个字段的重要性。Weights are used to indicate the importance of one searchable field relative to another.
functions 可选。Optional. 计分函数仅可应用于可筛选的字段。A scoring function can only be applied to fields that are filterable.
type 计分函数的必需项。Required for scoring functions. 指示要使用的函数类型。Indicates the type of function to use. 有效值包括 magnitude、freshness、distance 和 tag。Valid values include magnitude, freshness, distance, and tag. 可以在每个计分概要文件中包含多个函数。You can include more than one function in each scoring profile. 函数名称必须小写。The function name must be lower case.
boost 计分函数的必需项。Required for scoring functions. 用作原始分数乘数的正数。A positive number used as multiplier for raw score. 不得等于 1。It cannot be equal to 1.
fieldname 计分函数的必需项。Required for scoring functions. 计分函数仅可应用于作为索引字段集合一部分且可筛选的字段。A scoring function can only be applied to fields that are part of the field collection of the index, and that are filterable. 此外,每个函数类型都引入了其他限制(freshness 与 datetime 字段结合使用、magnitude 与 integer 或 double 字段结合使用、distance 与 location 字段结合使用。)。In addition, each function type introduces additional restrictions (freshness is used with datetime fields, magnitude with integer or double fields, and distance with location fields). 仅可按函数定义指定单个字段。You can only specify a single field per function definition. 例如,若要在同一概要文件中使用两次 magnitude,则需要包含两个定义 magnitude,每个字段一个。For example, to use magnitude twice in the same profile, you would need to include two definitions magnitude, one for each field.
interpolation 计分函数的必需项。Required for scoring functions. 定义从范围起始至范围结束的分数提升增量的斜率。Defines the slope for which the score boosting increases from the start of the range to the end of the range. 有效值包括 Linear(默认值)、Constant、Quadratic 和 Logarithmic。Valid values include Linear (default), Constant, Quadratic, and Logarithmic. 请参阅设置插值获取详细信息。See Set interpolations for details.
magnitude magnitude 计分函数用于改变基于数值字段的值范围的排名。The magnitude scoring function is used to alter rankings based on the range of values for a numeric field. 一些最常见的用法示例如下:Some of the most common usage examples of this are:

- 星级评分:根据“星级评分”字段中的值更改评分。- 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.
- 利润: 当两个文档相关时,零售商可能希望先提升具有较高利润的文档。- Margin: When two documents are relevant, a retailer may wish to boost documents that have higher margins first.
- 点击次数: 对于跟踪产品或页面点击行为的应用程序,可使用 magnitude 提升容易获得最多流量的项。- Click counts: For applications that track click through actions to products or pages, you could use magnitude to boost items that tend to get the most traffic.
- 下载次数: 对于跟踪下载的应用程序,magnitude 函数可提升下载次数最多的项。- Download counts: For applications that track downloads, the magnitude function lets you boost items that have the most downloads.
magnitude | boostingRangeStartmagnitude | boostingRangeStart 设置对其进行量值计分的范围的起始值。Sets the start value of the range over which magnitude is scored. 该值必须是整数或浮点数。The value must be an integer or floating-point number. 对于星级评分 1 到 4,这里应为 1。For star ratings of 1 through 4, this would be 1. 对于超过 50% 的利润率,这里应为 50。For margins over 50%, this would be 50.
magnitude | boostingRangeEndmagnitude | boostingRangeEnd 设置对其进行量值计分的范围的结束值。Sets the end value of the range over which magnitude is scored. 该值必须是整数或浮点数。The value must be an integer or floating-point number. 对于星级评分 1 到 4,这里应为 4。For star ratings of 1 through 4, this would be 4.
magnitude | constantBoostBeyondRangemagnitude | constantBoostBeyondRange 有效值为 true 或 false(默认)。Valid values are true or false (default). 设置为 true 时,完整的提升将继续应用到有一个目标字段值高于范围上限的文档。When set to true, the full boost will continue to apply to documents that have a value for the target field that’s higher than the upper end of the range. 如果为 false,此函数的提升不会应用到有一个目标字段值超出范围的文档。If false, the boost of this function won’t be applied to documents having a value for the target field that falls outside of the range.
freshness freshness 计分函数用于改变基于 DateTimeOffset 字段值的项的排名分数。The freshness scoring function is used to alter ranking scores for items based on values in DateTimeOffset fields. 例如,具有较新日期的项可以排在日期较旧的项之上。For example, an item with a more recent date can be ranked higher than older items.

也可以排列日历事件等具有未来日期的项,以便接近当前日期的项可以排在距离当前日期较远的将来的项之上。It is also possible to 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.

在当前服务版本中,范围的一端将固定为当前时间。In the current service release, one end of the range will be fixed to the current time. 另一端是基于 boostingDuration 的过去的时间。The other end is a time in the past based on the boostingDuration. 要提升将来时间的范围,请使用负 boostingDurationTo boost a range of times in the future, use a negative boostingDuration.

提升从最大范围和最小范围改变的比率由应用到计分概要文件的内插确定(请见下图)。The rate at which the boosting changes from a maximum and minimum range is determined by the Interpolation applied to the scoring profile (see the figure below). 若要反转应用的提升系数,请选择不超过 1 的提升系数。To reverse the boosting factor applied, choose a boost factor of less than 1.
freshness | boostingDurationfreshness | boostingDuration 设置一个有效期,超过这个有效期之后,针对特定文档的 Boosting 将停止。Sets an expiration period after which boosting will stop for a particular document. 请参阅以下语法和示例部分中的设置 boostingDurationSee Set boostingDuration in the following section for syntax and examples.
distance 距离计分函数用于影响基于其相对的参考地理位置远近程度的文档分数。The distance scoring function is used to affect the score of documents based on how close or far they are relative to a reference geographic location. 参考位置在形参中指定为查询的一部分(使用 scoringParameterquery 字符串选项),作为经纬度实参。The reference location is given as part of the query in a parameter (using the scoringParameterquery string option) as a lon,lat argument.
distance | referencePointParameterdistance | referencePointParameter 要在查询中传递以用作参考位置的参数。A parameter to be passed in queries to use as reference location. scoringParameter 是一个查询参数。scoringParameter is a query parameter. 有关查询参数的说明,请参阅搜索文档(Azure 认知搜索 REST API)See Search Documents (Azure Cognitive Search REST API) for descriptions of query parameters.
distance | boostingDistancedistance | boostingDistance 以公里为单位指示与参考位置(提升范围结束)之间距离的数字。A number that indicates the distance in kilometers from the reference location where the boosting range ends.
tag tag 计分函数用于影响基于文档和搜索查询中标记的文档的分数。The tag scoring function is used to affect the score of documents based on tags in documents and search queries. 将提升与搜索查询有共同标记的文档。Documents that have tags in common with the search query will be boosted. 搜索查询的标记作为每个搜索请求中的计分参数提供(使用 scoringParameterquery 字符串选项)。The tags for the search query is provided as a scoring parameter in each search request (using the scoringParameterquery string option).
tag | tagsParametertag | tagsParameter 要在查询中传递以指定特定请求标记的参数。A parameter to be passed in queries to specify tags for a particular request. scoringParameter 是一个查询参数。scoringParameter is a query parameter. 有关查询参数的说明,请参阅搜索文档(Azure 认知搜索 REST API)See Search Documents (Azure Cognitive Search REST API) for descriptions of query parameters.
functionAggregation 可选。Optional. 仅在函数已指定时适用。Applies only when functions are specified. 有效值包括:sum(默认值)、average、minimum、maximum和 firstMatching。Valid values include: sum (default), average, minimum, maximum, and firstMatching. 搜索分数是从多个变量(包括多个函数)中计算的单个值。A search score is single value that is computed from multiple variables, including multiple functions. 此属性指示所有函数的提升如何组合到随后应用到基本文档分数的单个聚合提升中。This attribute indicates how the boosts of all the functions are combined into a single aggregate boost that then is applied to the base document score. 基本分数基于从文档和搜索查询计算得出的 tf-idf 值。The base score is based on the tf-idf value computed from the document and the search query.
defaultScoringProfile 在执行搜索请求时,如果未指定任何计分概要文件,则使用默认计分(仅限 tf-idf)。When executing a search request, if no scoring profile is specified, then default scoring is used (tf-idf only).

可以在此处设置默认计分概要文件名称,以使 Azure 认知搜索在搜索请求中未给定任何特定概要文件时使用默认概要文件。A default scoring profile name can be set here, causing Azure Cognitive Search to use that profile when no specific profile is given in the search request.

设置内插Set interpolations

通过内插,可设置用于计分的坡度形状。Interpolations allow you to 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:

内插Interpolation 描述Description
linear 对于在最大和最小范围内的项目,将按递减的方式进行提升。For items that are within the max and min range, the boost applied to the item will be done in a constantly decreasing amount. Linear 是计分概要文件的默认内插。Linear is the default interpolation for a scoring profile.
constant 对于起始和结束范围内的项,将对排名结果应用恒定提升。For items that are within the start and ending range, a constant boost will be applied to the rank results.
quadratic 与具有不断减小的提升的线性内插相比,二次方最初以较小的速度递减,然后在接近结束范围时,以更高的间隔递减。In comparison to a Linear interpolation that has a constantly decreasing boost, Quadratic will initially decrease at smaller pace and then as it approaches the end range, it decreases at a much higher interval. tag 计分函数中不允许使用此内插选项。This interpolation option is not allowed in tag scoring functions.
logarithmic 与具有恒定递减提升的 Linear 内插相比,Logarithmic 最初以较大的速度递减,然后在接近结束范围时,以明显更小的间隔递减。In comparison to a Linear interpolation that has a constantly decreasing boost, Logarithmic will initially decrease at higher pace and then as it approaches the end range, it decreases at a much smaller interval. tag 计分函数中不允许使用此内插选项。This interpolation option is not allowed in tag scoring functions.

关系图上的常数、线性、二次、log10 线Constant, linear, quadratic, log10 lines on graph

设置 boostingDurationSet boostingDuration

boostingDurationfreshness 函数的属性。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. 例如,要在 10 天促销期内提升某个产品系列或品牌,应针对这些文档将 10 天期限指定为 "P10D"。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.

boostingDuration 必须设置为 XSD "dayTimeDuration" 值(ISO 8601 持续时间值的受限子集)的格式。boostingDuration must be formatted as an XSD "dayTimeDuration" value (a restricted subset of an ISO 8601 duration value). 它的模式为:“P[nD][T[nH][nM][nS]]”。The pattern for this is: "P[nD][T[nH][nM][nS]]".

下表提供几个示例。The following table provides several examples.

持续时间Duration boostingDurationboostingDuration
1 天1 day "P1D""P1D"
2 天 12 小时2 days and 12 hours "P2DT12H""P2DT12H"
15 分钟15 minutes "PT15M""PT15M"
30 天 5 小时 10 分钟 6.334 秒30 days, 5 hours, 10 minutes, and 6.334 seconds "P30DT5H10M6.334S""P30DT5H10M6.334S"

有关更多示例,请参阅 XML 架构:数据类型(W3.org 网站)For more examples, see XML Schema: Datatypes (W3.org web site).

另请参阅See also