-- 构建请求的biz列表
function get_search_biz_type_list(query, param)
-- 搜索biz配置列表
local search_biz_type_list = {}
if query.bizType then
if type(query.bizType) == "string" then
table.insert(search_biz_type_list, query.bizType)
else
search_biz_type_list = query.bizType
end
end
if search_biz_type_list == nil or #search_biz_type_list < 1 then
table.insert(search_biz_type_list, param.default_biz_type)
end
local search_list = {}
if not query._enable_multiplexed then
table.insert(search_list, {biz = param.default_biz_type, biz_type = search_biz_type_list})
return search_list
end
for _, type in ipairs(search_biz_type_list) do
table.insert(search_list, {biz = type, biz_type=type})
end
return search_list
end
function parse_diamond_config(query, param)
query._cluster_info = {}
-- 多引擎配置
local cluster_info_str = param.cluster_info
local cluster_info = setup.split(cluster_info_str, ";")
if not cluster_info then
return
end
for _, info in ipairs(cluster_info) do
local single_cluster_info = setup.split(info, ":")
if single_cluster_info and #single_cluster_info > 1 then
query._cluster_info[single_cluster_info[1]] = single_cluster_info[2]
end
end
end
-- 改写向量召回query
function rewrite_embedding_recall(query, switch, param)
-- 创建query
local que = {}
que._biz = query._biz
que._cluster_name = query._cluster_name
que.q = "NULL"
if really_need_search_embedding_recall(query) then
local qp_idlefish_table_qp_reserve_str_4rs_query_vector = query._qp_idlefish_table_qp_reserve_str_4rs_query_vector
local q_str = qp_idlefish_table_qp_reserve_str_4rs_query_vector .. "&n=" .. param.embedding_recall_search_hit
que.q = "sim_vec:" .. url_encode(q_str)
end
-- 改写attribues
if not switch.full_phase then
que.attribute = "item_id,bizType"
end
-- 改写rank
que.rank = { -- rank 子句
rank_profile = 'RecallScorer'
}
return que
end
-- 解析入口
function multi_parse(res_vec)
local items_search_lua_tables = {}
for _, p in ipairs(res_vec) do
-- p.res:value()执行异步并发请求
local res = p and p.res and p.res:value()
local biz = p and p.biz
... ...
local ret_table = res:getTable()
table.insert(items_search_lua_tables, {biz=biz, tbl = ret_table})
end
end