5

我在 Azure 搜索中有 3 组相同的(文本)项目,价格和积分各不相同。具有更高积分的更便宜的产品会被提升得更高。(价格比积分增加更多,并且反向增加)。

但是,我不断看到与此类似的搜索结果。

搜索在“约翰·米尔顿”上。

我明白了

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
                                        ]))
4

1 回答 1

7

Azure 搜索中的所有索引都拆分为多个分片,使我们能够快速扩大和缩小规模。当发出搜索请求时,它会独立地针对每个分片发出。然后将来自每个分片的结果集合并并按分数排序(如果没有定义其他排序)。重要的是要知道评分函数将每个文档中的查询词频率与其在所有文档中的频率加权,在分片中

这意味着在您的场景中,每个文档都有三个实例,即使禁用了评分配置文件,如果其中一个文档落在与其他两个不同的分片上,其分数将略有不同。索引中的数据越多,差异就越小(术语分布更均匀)。不可能假设任何给定文档将放置在哪个分片上。

一般来说,文档分数并不是排序文档的最佳属性。它应该只让您大致了解与结果集中的其他文档的文档相关性。在您的场景中,如果您将价格和/或点数字段标记为可排序,则可以按价格和/或点数对结果进行排序。您可以在此处找到如何使用 $orderby 查询参数的更多信息:https ://msdn.microsoft.com/en-us/library/azure/dn798927.aspx

于 2015-04-28T01:15:10.677 回答