上传数据
功能介绍
该接口用于KooSearch数据上传,可根据系统支持的模型上传数据,如电商行业userdata、itemdata、eventdata、orderdata模型,办公场景docdata模型,站内搜索itdata、actiondata模型。
- userdata:用户信息,是指消费者信息。电商用户上传此类数据可以根据年龄段和性别做个性化推荐及数据分析。
- itemdata:商品信息,是指物料信息。电商用户将自己的商品进行上传,最终用户可以通过搜索查看到有哪些具体的商品以及商品的详细情况。
- eventdata:事件信息,是指用户在应用上的行为信息,如用户搜索、点击、收藏、加购、下单、支付等,根据这些数据对用户做个性化推荐及数据分析。
- orderdata:订单信息,用户对商品下的订单数据信息,用于统计分析商品销量及用户喜好,提升点击到支付的转化。
- docdata:文档数据,用户在办公场景下,上传文档内容。
- itdata:IT领域结构化数据,用户在站内搜索场景下根据数据模型字段上传结构化数据。
- actiondata:用户行为数据,支持站内场景,根据站内用户行为数据对用户行为进行统计分析。
URI
POST /v1/{project_id}/data-collections/{dataCollectionName}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID。获取方法请参见获取项目ID和名称。 |
dataCollectionName |
是 |
String |
系统支持电商行业模型、办公场景、站内场景。 枚举值:
|
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
Content-Type |
是 |
String |
请求体参数类型,该字段必须设置为:application/json。 最小长度:0 最大长度:20 |
application_id |
是 |
String |
应用ID。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
requestId |
否 |
String |
请求唯一编号,仅适用于电商搜索。 |
timestamp |
否 |
String |
请求时间戳,仅适用于电商搜索。
|
dynamicField |
否 |
Boolean |
是否开启动态字段,默认值为false,仅适用于站内搜索。
说明:
新增的字段不会用于搜索匹配,只能用于过滤和排序。
|
records |
是 |
上传数据集。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
userId |
是 |
String |
用户唯一标识。 |
age |
是 |
Integer |
年龄。 |
gender |
是 |
String |
性别。 枚举值:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
spuId |
否 |
String |
商品信息聚合的最小单位,和事件数据详情的spu_id需保持一致。 |
spuName |
否 |
String |
SPU名称。 |
skuId |
否 |
String |
SKUID。 |
skuName |
否 |
String |
SKU名称。 |
goodsId |
否 |
String |
商品ID。 |
firstClass |
否 |
String |
一级分类。 |
firstClassId |
否 |
String |
一级分类编号。 |
secondClass |
否 |
String |
二级分类。 |
secondClassId |
否 |
String |
二级分类编号。 |
thirdClass |
否 |
String |
三级分类。 |
thirdClassId |
否 |
String |
三级分类编号。 |
minClass |
否 |
String |
最小分类。 |
minClassId |
否 |
String |
最小分类编号。 |
goodsName |
否 |
String |
商品名称。 |
goodsDesc |
否 |
Array of strings |
商品描述。 |
productBrand |
否 |
String |
商品所属品牌。 |
priceType |
否 |
Integer |
价格类型。 |
activityType |
否 |
Integer |
商品活动类型。 |
goodsPrice |
否 |
Float |
商品优惠之后的价格。 |
marketPrice |
否 |
Float |
商品原始价格。 |
goodsDcn |
否 |
Float |
商品折扣。 |
goodsLink |
否 |
String |
商品链接。 |
imageLink |
否 |
String |
图片链接。 |
goodsStock |
否 |
Integer |
商品库存。 |
onlineFlag |
否 |
Boolean |
在架状态。 |
shippingWeight |
否 |
Float |
物品重量。 |
size |
否 |
String |
尺寸。 |
color |
否 |
String |
颜色。 |
gender |
否 |
String |
商品适用性别。 |
commentCnt |
否 |
Integer |
评论数。 |
score |
否 |
Float |
评分。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
evtType |
否 |
String |
事件类型数据详情。 枚举值:
|
evtOccurTime |
否 |
String |
事件发生时间戳。 |
evtProperty |
否 |
Object |
为事件数据详情,填evtType字段对应的行为类型的数据,如evtType为搜索,则必填query,选填search_type和cp_extra_property,用json数组返回。 |
recommendId |
否 |
String |
请求华为搜索接口返回ID。 |
recommendInfo |
否 |
String |
推荐返回信息。 |
brandName |
否 |
String |
品牌站名称。 |
isLogin |
否 |
Boolean |
是否登录。 |
userId |
否 |
String |
用户编号。 |
visitorId |
否 |
String |
游客编号。 |
os |
否 |
String |
操作系统。 |
platformType |
否 |
String |
平台类型。 |
appId |
否 |
String |
应用编号。 |
appName |
否 |
String |
应用名称。 |
appVer |
否 |
String |
应用版本。 |
deviceId |
否 |
String |
设备ID。 |
deviceBrand |
否 |
String |
设备品牌。 |
deviceName |
否 |
String |
设备型号。 |
deviceProdName |
否 |
String |
设备产品名。 |
packageName |
否 |
String |
应用包名。 |
romVer |
否 |
String |
ROM版本。 |
isFirstDay |
否 |
Boolean |
是否首次启动App。 |
carrier |
否 |
String |
运营商。 |
networkType |
否 |
String |
网络类型。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
orderId |
否 |
String |
订单号(非订单ID)。 |
userId |
否 |
String |
用户的唯一编号。 |
goodsId |
否 |
String |
商品ID。 |
skuId |
否 |
String |
SKUID(和商品表一致)。 |
spuId |
否 |
String |
SPUID(和商品表一致)。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
docAttachId |
是 |
String |
文档ID。 |
docAttachName |
是 |
String |
文档名称。 |
docUrl |
否 |
String |
文档URL。 |
docPageInfo |
否 |
Array of DocPageInfo objects |
文档页面信息。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
attachDirTitle |
否 |
String |
文档页面小标题。 |
attachPageNo |
否 |
String |
文档原始页码。 |
attachPageNoNew |
否 |
Long |
文档页码(排序可用)。 |
attachParagraph |
否 |
Array of strings |
文档页面片段内容。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
id |
是 |
String |
主键。 |
type |
否 |
String |
资源类型。例如:博客、论坛、问答等。 |
title |
否 |
String |
标题。在“上传数据”时为必填项,在“更新数据”时为选填项。 |
description |
否 |
String |
描述。 |
body |
否 |
String |
内容。 |
author |
否 |
String |
作者。 |
create_time |
否 |
String |
创建时间,格式:"yyyy-MM-ddTHH:mm:ss.SSSZ"。 |
update_time |
否 |
String |
更新时间,格式:"yyyy-MM-ddTHH:mm:ss.SSSZ"。 |
tags |
否 |
String |
标签。 |
index_hot_word |
否 |
String |
索引热词。针对该资源,需要建立强关联索引词。 |
pic |
否 |
String |
图片。 |
price |
否 |
Float |
资源单价。 |
high_quality |
否 |
Integer |
标记:是否是优质资源。
|
free |
否 |
Integer |
是否免费。
|
likes |
否 |
Integer |
点赞数。 |
view |
否 |
Integer |
阅读数。 |
comment |
否 |
Integer |
评论数。 |
collections |
否 |
Integer |
收藏数。 |
focus |
否 |
Integer |
关注数。 |
reports |
否 |
Integer |
转发数。 |
fans |
否 |
Integer |
粉丝数。 |
stemp_count |
否 |
Integer |
踩数。 |
posts_count |
否 |
Integer |
回复数。 |
quality_score |
否 |
Integer |
质量分。 |
is_original |
否 |
Integer |
是否原创。
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
userAction |
是 |
String |
用户行为数据详情。 枚举值:
|
time |
是 |
Long |
时间。 UNIX时间戳(UTC时间)。 最小值:0 |
requestId |
是 |
String |
请求ID。填写搜索数据集/查询热搜词接口返回的requestId。 |
position |
是 |
Integer |
位置。计算方式:(page-1)*hitsPerPage + 在当前页的位置。 |
docId |
否 |
String |
文档ID。 当userAction字段值为非"click_hotword"时,文档ID必填。 |
hotword |
否 |
String |
热搜词。 当userAction字段值为"click_hotword"时,热搜词必填。 |
响应参数
无
请求示例
- 站内搜索场景结构化数据上传。示例中开启了动态字段,将dynamicField参数指定为true,可以添加新字段“delete_time”(时间类型,格式:yyyy-MM-ddTHH:mm:ss.SSSZ)和“weight”(double类型)。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/itdata { "records" : [ { "id" : "blog-100623122", "type" : "blog", "title" : "获取对象操作", "description" : "1.通过 id 获取对象 var $cr=$('#cr');//jQuery对象 var cr=document.getElementById('cr');//DOM对象 2.通过 name 获取对象 Js代码 : $(\"div[id]\") ...", "body" : "1.通过 id 获取对象 var $cr=$('#cr');//jQuery对象 var cr=document.getElementById('cr');//DOM对象 2.通过 name 获取对象 Js代码 : $(\"div[id]\") 选择所有含有id属性的div元素 $(\"input[name='newsletter']\") 选择所有的name属性等于'newsletter'的input元素 $(\"input[name!='newsletter']\") 选择所有的name属性不等于'newsletter'的input元素 $(\"input[name^='news']\") 选择所有的name属性以'news'开头的input元素 $(\"input[name$='news']\") 选择所有的name属性以'news'结尾的input元素 $(\"input[name*='man']\") 选择所有的name属性包含'news'的input元素 $(\"input[id][name$='man']\") 可以使用多个属性进行联合选择,该选择器是得到所有的含有id属性并且那么属性以man结尾的元素 3. 4.判断checkbox 是否选中 方法一: if ($(\"#checkbox-id\").get(0).checked) { // do something } 方法二: if($('#checkbox-id').is(':checked')) { // do something } 方法三: if ($('#checkbox-id').attr('checked')) { // do something } function checkInfo(){ $(\"input[name='org3.otherValues']\").each( function(){ if($(this).get(0).checked){ return true; } }); var org3_ids=$(\"#org3_ids\").val(); if(org3_ids!=''){ return true; } 参考资料: http://blog.csdn.net/a1943206465/article/details/54893091 转载于:https://my.oschina.net/ruanjun/blog/1488931", "author" : "Micah Lee", "create_time" : "2017-07-26T14:28:00.000+0800", "update_time" : "2019-09-08T11:23:18.000+0800", "delete_time" : "2023-04-06T12:20:36.000+0800", "tags" : "获取对象,jQuery", "index_hot_word" : "jQuery,Js,获取对象", "pic" : "www.img.com/js.png", "price" : 1, "high_quality" : "1", "free" : 1, "likes" : 2, "view" : 26, "comment" : 1, "collections" : 3, "focus" : 4, "reports" : 2, "fans" : 2, "stemp_count" : 1, "posts_count" : 2, "weight" : 0.8 } ], "dynamicField" : true }
- 用户基础信息导入。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/userdata { "records" : [ { "userId" : "0000350019", "age" : "25", "gender" : "male" }, { "userId" : "0000350015", "age" : "27", "gender" : "female" } ], "requestId" : "1c4789a9520397387b271f7266b92c11", "timestamp" : "1613757496" }
- 用户事件上报。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/eventdata { "records" : [ { "deviceId" : "12cd7cf2-da74-4182-afb7-6c90cc41393a_ys", "evtOccurTime" : "1661485148", "os" : "Android", "deviceProdName" : "pro20", "brandName" : "adorawe", "evtProperty" : [ { "goodsName" : "2022夏季新款短袖T恤男潮流纯棉宽松上衣学生简约男rty", "sourceModule" : "Home_guessYouLike", "query" : "短袖", "position" : "", "spuId" : "992230" } ], "appName" : "banggood", "deviceName" : "rm3597", "carrier" : "CMCC", "platformType" : "Android", "deviceBrand" : "HUAWEI", "userId" : "16723065", "appVer" : "7.2.0", "evtType" : "search", "networkType" : "5G", "appId" : "7.2.1", "isLogin" : "1" } ], "requestId" : "", "timestamp" : "1661485248" }
- 办公场景文档信息上传。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/docdata { "records" : [ { "docAttachName" : "黄金时代", "docAttachId" : "f32923312eda4f07aa33bea3d1ccb8a9", "docUrl" : "/path/book", "docPageInfo" : [ { "attachPageNo" : "第1页", "attachPageNoNew" : 1, "attachDirTitle" : "这东西无比重要", "attachParagraph" : [ "当然,我对此有不同的意见,在我看来,这东西无比重要,就如我之存在本身。天色微微向晚,天上飘着懒洋洋的云彩。下半截沉在黑暗里,上半截仍浮在阳光中。" ] }, { "attachPageNo" : "第2页", "attachPageNoNew" : 2, "attachDirTitle" : "半明半暗的云", "attachParagraph" : [ "那一天我二十一岁,在我一生的黄金时代。我有好多奢望。我想爱,想吃,还想在一瞬间变成天上半明半暗的云。", "后来我才知道,生活就是个缓慢受锤的过程,人一天天老下去,奢望也一天天消失,最后变得像挨了锤的牛一样。" ] }, { "attachPageNo" : "第3页", "attachPageNoNew" : 3, "attachDirTitle" : "锤不了我", "attachParagraph" : [ "可是我过二十一岁生日时没有预见到这一点。我觉得自己会永远生猛下去,什么也锤不了我。", "那天晚上我请陈清扬来吃鱼,所以应该在下午把鱼弄到手。到下午五点多钟我才想起到戽鱼的现场去看看。还没走进那条小河岔,两个累颇族孩子就从里面一路打出来,烂泥横飞,我身上也挨了好几块,直到我拎住他们的耳朵,他们才罢手。" ] } ] } ] }
- 商品信息导入。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/itemdata { "records" : [ { "spuId" : "1615411", "spuName" : "price_type", "skuId" : "POA6228532", "skuName" : "POA6228533", "goodsId" : "1715166_POA7260552_EN", "countrySite" : "CN", "firstClass" : "first_class", "firstClassId" : "3580", "secondClass" : "secondClass", "secondClassId" : "358001", "thirdClass" : "thirdClass", "thirdClassId" : "35800101", "minClass" : "minClass", "minClassId" : "35800101", "goodsName" : "雪花秀人参水", "goodsDesc" : "专注于肌肤护理", "productBrand" : "欧莱雅", "priceType" : 1, "activityType" : 1, "goodsPrice" : 1280, "marketPrice" : 1900, "goodsDcn" : 0, "goodsLink" : "https://www.xxxx/ru/unknow-0/p-1615588.html", "imageLink" : "https://www.xxxx/ru/unknow-0/p-1615588.html", "goodsStock" : 1000, "onlineFlag" : true, "shippingWeight" : 1, "size" : "16px", "color" : "Blue", "gender" : "female", "commentCnt" : 50, "score" : 99.9 }, { "spuId" : "1615411", "spuName" : "price_type", "skuId" : "POA6228532", "skuName" : "POA6228533", "goodsId" : "1715166_POA7260552_EN", "countrySite" : "CN", "firstClass" : "first_class", "firstClassId" : "3580", "secondClass" : "secondClass", "secondClassId" : "358001", "thirdClass" : "thirdClass", "thirdClassId" : "35800101", "minClass" : "minClass", "minClassId" : "35800101", "goodsName" : "飞利浦电动剃须刀S1008", "goodsDesc" : "科技创造美好生活,专注男性洁面护理", "productBrand" : "飞利浦", "priceType" : 1, "activityType" : 1, "goodsPrice" : 1280, "marketPrice" : 1900, "goodsDcn" : 0, "goodsLink" : "https://www.xxxx/ru/unknow-0/p-1615588.html", "imageLink" : "https://www.xxxx/ru/unknow-0/p-1615588.html", "goodsStock" : 1000, "onlineFlag" : true, "shippingWeight" : 1, "size" : "16px", "color" : "Blue", "gender" : "female", "commentCnt" : 50, "score" : 99.9 } ], "requestId" : "156155448", "timestamp" : "47474747786" }
- 订单数据导入。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/orderdata { "records" : [ { "orderId" : "13541", "userId" : "1357861322", "shopId" : "yf-125037", "goodsId" : "WZWS13452013_en", "skuId" : "WZWS13452013", "spuId" : "881120" }, { "orderId" : "13542", "userId" : "1357861323", "shopId" : "yf-125038", "goodsId" : "WZWS13452014_en", "skuId" : "WZWS13452014", "spuId" : "881121" }, { "orderId" : "13543", "userId" : "1357861324", "shopId" : "yf-125039", "goodsId" : "WZWS13452015_en", "skuId" : "WZWS13452015", "spuId" : "881122" }, { "orderId" : "13544", "userId" : "1357861325", "shopId" : "yf-125040", "goodsId" : "WZWS13452016_en", "skuId" : "WZWS13452016", "spuId" : "881123" } ], "requestId" : "", "timestamp" : "1661485248" }
- 用户行为数据上传(userAction为click_hotword)。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/actiondata { "records" : [ { "userAction" : "click_hotword", "time" : 1682576212, "requestId" : "35de280109e14fb6a062db965ac4a266", "position" : 1, "hotword" : "hello" } ] }
- 用户行为数据上传(userAction为非click_hotword)。
https://koosearch.myhuaweicloud.com/v1/{project_id}/data-collections/actiondata { "records" : [ { "userAction" : "exposure", "time" : 1682576212, "requestId" : "35de280109e14fb6a062db965ac4a266", "position" : 1, "docId" : "blog-9999999" } ] }
响应示例
状态码: 200
返回信息。
{ "status" : "200", "message" : "success", "data" : null }
状态码: 400
详见错误码分类。
{ "status" : "2013", "message" : "数据上报类型不支持", "data" : null }
状态码: 500
服务器请求失败。
{ "status" : 1000, "message" : "服务异常", "data" : null }
状态码
状态码 |
描述 |
---|---|
200 |
返回信息。 |
400 |
详见错误码分类。 |
500 |
服务器请求失败。 |
错误码
请参见错误码。