有货个性化搜索.md
10.3 KB
1. index里的商品权重
- productindex.brandPageProdBoost
- productindex.sortPageProdBoost
- productindex.searchPageProdBoost
- productindex.newPageProdBoost
redis的hash类型的key:(key为f0-f54, f0-f30为商品特征/f31之后为用户特征)
- siweight:1 -- 品牌页
- siweight:2 -- 品类页
- siweight:3 -- 模糊搜索页
- siweight:4 -- 新品到着页
每个页面(pageId)中每个skn权重的计算过程:
- 根据pageId到redis取各个特征(f0-f30)的权重(value)
- 根据skn到product_feature表获取各个特征(skn_7_days_view【对应f0】...)的权重(boost)
- 根据feature获取对应的放大倍数(zoom)
总结就是,每个页面遍历所有商品特征(f0-f30),对上述这个值的乘积再求和
pageBoost(pageId) = ∑(value * boost * zoom)
2. 搜索的时候根据用户特征算权重
参数: uid、pageId
redis中user的特征值
si: 用户特征数据结构
- hkey hvalue
- s1:10001 10
- s2:10001 15
- s3:10001 25
- 存储为:
- fid = 10001 (小分类ID)
- target = smallSortId (小分类)
- featureValMap = 10, s2->15, s3->25>
- featureZoomMap = 100, s2->100, s3->100> (feature.XML配置)
转换为 uid 关联 List(SearchFeature)
计算SearchFeature(target、fid、boost)
boost的计算过程
userBoost(uid, pageId) = ∑(value * boost * zoom)
这里面的boost是根据pageId查询siweight:获取到的(对应的特征为f31-f54),其值可能是负数(比如最近f0)
3. 将product和user的权重关联到search
对于SearchFeature,进行should直接加分
boolQueryBuilder.should(QueryBuilders.termQuery(entry.getTargetParam(), entry.getParamValues()).boost(entry.getBoost()));
对于pageBoost的处理
new_score = old_score * log(2 + factor * page_boosts)
- factor:模糊搜索页面为0.01,其他页面为2;
疑问:
- product_feature表数据的来源?
- ProductFeatureLogicService里对redis只初始化一次?
线上数据样例
pageBoost
curl 'localhost:8080/yohosearch/tools/pageBoost?pageId=all'
{
"code": 200,
"data": {
"1": {
"f45": "0.0",
"f50": "0.087308899",
"f21": "0.010634153",
"f26": "-7.8375845",
"f19": "-0.17392449",
"f38": "1.2880194",
"f36": "0.62151939",
"f0": "-14.951955",
"f46": "-5.4284705E-5",
"f25": "0.57424122",
"f31": "0.0",
"f42": "0.0",
"f34": "0.49243373",
"f52": "0.20621356",
"f1": "1.1856834",
"f16": "-0.047698051",
"f24": "0.50929797",
"f37": "1.3186802",
"f11": "2.3076746",
"f6": "0.4713608",
"f9": "-0.69676375",
"f39": "0.0",
"f30": "-5.9078178",
"f47": "-0.087741099",
"f29": "4.1414223",
"f8": "2.9859776",
"f53": "0.029975411",
"f13": "-0.063685365",
"f22": "-0.61742109",
"f33": "0.11123929",
"f18": "-0.95059365",
"f4": "7.3057432",
"f3": "7.5226822",
"f51": "-0.029828858",
"f44": "0.0",
"f5": "10.150745",
"f7": "0.0",
"f54": "0.68256199",
"f12": "-0.38859525",
"f43": "0.0",
"f35": "1.0367129",
"f17": "-0.2252354",
"f20": "-0.17667589",
"f15": "-0.047746774",
"f41": "0.0",
"f23": "-0.13137653",
"f40": "0.0",
"f27": "-0.10473914",
"f28": "4.1876559",
"f32": "0.0",
"f48": "0.019835224",
"f2": "-9.1708536",
"f14": "-0.054573208",
"f49": "-0.017519267",
"f10": "1.6888559"
},
"2": {
"f36": "0.97303694",
"f54": "0.66588873",
"f30": "0.86932856",
"f33": "-0.07566642",
"f40": "-0.30072686",
"f44": "-0.14177813",
"f35": "0.5550046",
"f19": "-1.8316269",
"f34": "0.37242088",
"f46": "0.68901753",
"f29": "2.1036365",
"f38": "4.975234",
"f17": "1.8216048",
"f6": "-1.7348145",
"f22": "-1.2953041",
"f14": "0.54869372",
"f12": "1.0888249",
"f16": "0.061326832",
"f5": "14.723831",
"f52": "-0.23299435",
"f43": "0.27967569",
"f2": "-0.85429382",
"f47": "-0.31142733",
"f23": "-1.304587",
"f51": "0.20620462",
"f10": "2.5541799",
"f42": "0.091125794",
"f28": "2.1380782",
"f53": "0.3856276",
"f13": "-0.49690872",
"f4": "5.5338478",
"f21": "1.6246915",
"f20": "-1.4944824",
"f32": "-0.47345328",
"f45": "0.72154766",
"f48": "0.17376179",
"f3": "4.9629307",
"f50": "-0.16082868",
"f39": "-0.72696656",
"f31": "-0.34979609",
"f9": "-1.05707",
"f24": "1.6590664",
"f27": "-3.5020339",
"f0": "-2.0985901",
"f15": "0.12005123",
"f18": "-0.08695402",
"f25": "1.6886462",
"f7": "0.0",
"f41": "-0.68575919",
"f49": "-0.012422436",
"f8": "-4.6805906",
"f1": "1.6027443",
"f26": "-0.57401025",
"f37": "1.1208721",
"f11": "3.3850117"
},
"3": {
"f47": "0.15185456",
"f22": "-0.66088557",
"f52": "0.16267362",
"f27": "-2.2247109",
"f54": "0.64532751",
"f51": "0.18877281",
"f14": "-0.54751122",
"f21": "0.49728435",
"f36": "0.81681317",
"f6": "-0.0191852",
"f3": "6.9761372",
"f46": "0.21782744",
"f29": "1.1633264",
"f48": "-0.16456035",
"f44": "0.23829049",
"f30": "-0.4718146",
"f34": "0.22220892",
"f10": "1.8251585",
"f32": "-0.021210853",
"f35": "0.60733849",
"f15": "0.94462562",
"f18": "-0.95911992",
"f1": "-4.5390935",
"f12": "0.83306158",
"f26": "-0.20626777",
"f38": "5.0364733",
"f17": "1.3557355",
"f31": "0.0041405247",
"f4": "7.4093475",
"f23": "-0.41182885",
"f11": "3.3704135",
"f39": "-0.24190955",
"f40": "-0.23277462",
"f43": "0.3863565",
"f8": "-2.1326935",
"f41": "-0.90839493",
"f53": "-0.055345807",
"f33": "-0.32141256",
"f5": "14.134021",
"f42": "0.5250051",
"f2": "-11.591382",
"f0": "-2.0459023",
"f49": "0.06589552",
"f7": "0.0",
"f28": "1.173838",
"f25": "0.96549189",
"f19": "-0.93399692",
"f24": "0.89981407",
"f9": "0.25455642",
"f50": "-0.15266939",
"f13": "-1.2128493",
"f37": "1.2420933",
"f16": "0.86031246",
"f20": "-1.0622554",
"f45": "0.9019978"
},
"4": {
"f30": "4.5504007",
"f35": "1.1340431",
"f40": "-0.90053058",
"f24": "1.3311378",
"f11": "1.2294296",
"f22": "-1.2860192",
"f1": "4.281148",
"f12": "-3.0378478",
"f29": "2.2184522",
"f21": "-0.319819",
"f9": "-3.1870317",
"f13": "-0.45066145",
"f18": "-0.5963394",
"f48": "0.210363",
"f44": "-0.22618662",
"f46": "-0.25105405",
"f25": "1.5284107",
"f26": "-2.13095",
"f28": "1.5155201",
"f20": "2.7307673",
"f41": "1.559839",
"f53": "-0.17862597",
"f14": "1.0954876",
"f54": "0.79681087",
"f3": "3.8243499",
"f8": "-0.037173711",
"f5": "8.2764111",
"f23": "-0.92951035",
"f52": "0.15142061",
"f15": "-1.1554281",
"f34": "0.085361436",
"f7": "0.0",
"f43": "-1.0104663",
"f4": "3.1258235",
"f51": "0.15113536",
"f32": "-0.038247921",
"f0": "-7.0478129",
"f2": "-2.8109138",
"f50": "-0.088835299",
"f27": "-2.0421329",
"f39": "-0.033363361",
"f45": "-2.6229432",
"f47": "-0.01816283",
"f6": "-4.0307837",
"f31": "-1.6729915",
"f10": "7.4476733",
"f17": "-3.3110654",
"f42": "-1.6030066",
"f49": "-0.11615948",
"f19": "2.7948155",
"f36": "0.31999111",
"f16": "-0.7702207",
"f38": "8.1910887",
"f33": "-0.14072298",
"f37": "3.8080981"
}
},
"message": "success"
}
userBoost
curl 'localhost:8080/yohosearch/tools/userBoost?uid=13838876'
{
"code": 200,
"data": {
"s1:271": "0.0",
"b8:2490": "0.0",
"b2:144": "0.0",
"s7:271": "0.0",
"b4:144": "0.0",
"b6:583": "0.0",
"g4:1": "0.0",
"g4:3": "1.0",
"g7:3": "0.0",
"g1:1": "0.0",
"g1:3": "0.0",
"g6:3": "0.0",
"s4:147": "0.0",
"s8:147": "1.0",
"g6:1": "0.0",
"s6:147": "0.0",
"b8:144": "0.0",
"b4:583": "0.0",
"g5:3": "0.5",
"s5:271": "0.5",
"b5:583": "0.0",
"b2:2490": "0.0",
"s1:147": "0.0",
"b3:583": "0.0",
"b3:2490": "0.0",
"s5:147": "0.5",
"s6:271": "0.0",
"s7:147": "0.0",
"b5:2490": "0.5",
"s2:271": "0.0",
"b1:144": "0.0",
"g5:1": "0.5",
"b7:583": "0.0",
"b6:144": "0.0",
"s4:271": "1.0",
"b1:2490": "0.0",
"g8:3": "0.0",
"g3:3": "0.0",
"b4:2490": "1.0",
"b7:144": "0.0",
"s3:271": "0.0",
"g2:1": "0.0",
"b1:583": "0.0",
"b3:144": "0.0",
"b5:144": "0.5",
"g3:1": "0.0",
"s8:271": "0.0",
"s3:147": "0.0",
"g7:1": "0.0",
"b6:2490": "0.0",
"b7:2490": "0.0",
"b2:583": "0.0",
"g2:3": "0.0",
"s2:147": "0.0",
"g8:1": "1.0",
"b8:583": "1.0"
},
"message": "success"
}