企业搜索服务 KooSearch-上传数据:请求示例

时间:2023-11-01 16:16:26

请求示例

  • 站内搜索场景结构化数据上传。示例中开启了动态字段,将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"  } ]}
support.huaweicloud.com/api-koosearch/data-collection.html