我有3套相同的(文本)项目在Azure搜索不同的价格和点。价格较低且得分较高的产品被推高。(价格的上涨幅度大于点数,而价格则相反)。
然而,我一直看到类似于此的搜索结果。
搜索“约翰·弥尔顿”。
我得到了
Product="Id = 2-462109171829-1, Price=116.57, Points= 7, Name=Life of Schamyl / John Milton Mackie, Description=.", Score=32.499783
Product="Id = 2-462109171829-2, Price=116.40, Points= 9, Name=Life of Schamyl / John Milton Mackie, Description=.", Score=32.454872
Product="Id = 2-462109171829-3, Price=115.64, Points= 9, Name=Life of Schamyl / John Milton Mackie, Description=.", Score=32.316270我希望评分顺序是这样的,以最低的价格第一。
Product="Id = 2-462109171829-3, Price=115.64, Points= 9, Name=Life of Schamyl / John Milton Mackie, Description=.", Score=
Product="Id = 2-462109171829-2, Price=116.40, Points= 9, Name=Life of Schamyl / John Milton Mackie, Description=.", Score=
Product="Id = 2-462109171829-1, Price=116.57, Points= 7, Name=Life of Schamyl / John Milton Mackie, Description=.", Score=我漏掉了什么,或者轻微的得分变化可以接受?
索引定义为
let ProductDataIndex =
let fields =
[|
new Field (
"id",
DataType.String,
IsKey = true,
IsSearchable = true);
new Field (
"culture",
DataType.String,
IsSearchable = true);
new Field (
"gran",
DataType.String,
IsSearchable = true);
new Field (
"name",
DataType.String,
IsSearchable = true);
new Field (
"description",
DataType.String,
IsSearchable = true);
new Field (
"price",
DataType.Double,
IsSortable = true,
IsFilterable = true)
new Field (
"points",
DataType.Int32,
IsSortable = true,
IsFilterable = true)
|]
let weightsText =
new TextWeights(
Weights = ([|
("name", 4.);
("description", 2.)
|]
|> dict))
let priceBoost =
new MagnitudeScoringFunction(
new MagnitudeScoringParameters(
BoostingRangeStart = 1000.0,
BoostingRangeEnd = 0.0,
ShouldBoostBeyondRangeByConstant = true),
"price",
10.0)
let pointsBoost =
new MagnitudeScoringFunction(
new MagnitudeScoringParameters(
BoostingRangeStart = 0.0,
BoostingRangeEnd = 10000000.0,
ShouldBoostBeyondRangeByConstant = true),
"points",
2.0)
let scoringProfileMain =
new ScoringProfile (
"main",
TextWeights =
weightsText,
Functions =
new List<ScoringFunction>(
[
priceBoost :> ScoringFunction
pointsBoost :> ScoringFunction
]),
FunctionAggregation =
ScoringFunctionAggregation.Sum)
new Index
(Name = ProductIndexName
,Fields = fields
,ScoringProfiles = new List<ScoringProfile>(
[
scoringProfileMain
]))发布于 2015-04-28 01:15:10
Azure搜索中的所有索引都被分割成多个碎片,这样我们就可以快速升级和缩小规模。当一个搜索请求被发出时,它将独立地针对每个碎片发出。然后将每个碎片的结果集合并并按分数排序(如果没有定义其他排序)。重要的是要知道,评分函数对每个文档中的查询词频率与其在所有文档中的频率、在切分中的查询频率进行加权!
这意味着,在您的场景中,每个文档有三个实例,即使禁用了得分配置文件,如果其中一个文档位于与另两个文档不同的碎片上,则其得分将略有不同。索引中的数据越多,差异就越小(更均匀的项分布)。不可能假设将任何给定的文档放在哪个碎片上。
一般来说,文档评分不是排序文档的最佳属性。它只会给您提供与结果集中的其他文档相关联的一般文档感。在您的场景中,如果将price和/或points字段标记为可排序,则可以按价格和/或点排序结果。您可以在这里找到关于如何使用$orderby查询参数的更多信息:https://msdn.microsoft.com/en-us/library/azure/dn798927.aspx
https://stackoverflow.com/questions/29814079
复制相似问题