Guide
Smart Search
Personalisation
8 min
the personalisation is an add on feature to enable the option, please submit a support ticket when a customer enters a physical shop, they may express their preferences to an in store assistant by highlighting the colours they like, the brands they prefer and what they have purchased before the in store assistant would then use this information to show the customer products they are most likely interested in first, before showing them any others that still may be suitable klevu a i is your online assistant this personalisation can be provided in two ways including some information about the customer's browsing history with each request defining your own boosting rules based on the information you already know about the customer you can read more about how this works in our personalisation guide https //help klevu com/support/solutions/articles/5000871361 do you offer apis for personalisation browsing history if you provide the ids of products which the customer has recently interacted with, the klevu a i will figure out the common aspects of those products and influence the search results the easiest way to highlight this is with an example in the json below, the four record ids provided within context represent the products that a customer has clicked on before making a search they all have the brand 'mnh' there may be other attributes those products have in common, such as price, color, material, etc , however, we have specified in the query that we are only interested in personalisation based on 'brand' when you execute the query, you will see some brand 'mnh' results are coming first note that the impact of personalisation is not always apparent klevu is clever if the customer has recently been looking at 'shoes' but now they are searching for 'washing machines', klevu will know to disregard any interactions that are not relevant to the current search query { "tab" "examples", "url" "https //{{hostname}}/cs/v2/search", "name" "history", "method" "post", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[], "bodydataparameters" \[ { "kind" "required", "name" "enablepersonalisation", "type" "boolean", "description" "this must be set to 'true' for enabling personalisation on a particular request if set to 'false', the recent objects within the context object will be ignored" }, { "kind" "optional", "name" "fields", "type" "array", "description" "this is an optional field by default, klevu will analyse all attributes of the records the customer has interacted with, in order to determine the common patterns if you prefer to focus on particular aspects, for example brand or price, specify those attributes within this object " }, { "kind" "optional", "name" "recentobjects", "type" "object", "description" "use this object to specify the records (e g products, categories, etc ) that were recently interacted with by a customer \n\nplease only specify one recentobject object per record type, one for all klevu product entries, another for all klevu cms pages visited, etc \n\neach recentobject object may contain multiple record objects (e g 5 recently viewed products) the most recently clicked record should be the first element in the array " } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "3xlvmt855lgkjoht0npxg", "code" "{\n meta {\n qtime 22,\n responsecode 200\n },\n queryresults \[\n {\n id \\"productsearch\\",\n meta {\n qtime 7,\n noofresults 5,\n totalresultsfound 104,\n typeofsearch \\"wildcard and\\",\n offset 0,\n debugginginformation {},\n notificationcode 1,\n searchedterm \\"short\\",\n apikey \\"klevu 156925593843210765\\",\n ispersonalised false\n },\n records \[\n {\n name \\"erika running short\\",\n id \\"31366431014974\\",\n brand \\"ksd\\"\n },\n {\n name \\"erika running short\\",\n id \\"31366431080510\\",\n brand \\"ksd\\"\n },\n {\n name \\"erika running short\\",\n id \\"31366431146046\\",\n brand \\"ksd\\"\n },\n {\n name \\"meteor workout short\\",\n id \\"31366465781822\\",\n brand \\"kke\\"\n },\n {\n name \\"hawkeye yoga short\\",\n id \\"31366465126462\\",\n brand \\"mnh\\"\n }\n ],\n filters \[]\n }\n ]\n}", "language" "200", "customlabel" "" } ], "selectedlanguageid" "3xlvmt855lgkjoht0npxg" }, "examples" { "languages" \[ { "id" "jsu7dlyyj euh63ysp682", "code" "{\n \\"recordqueries\\" \[\n {\n \\"id\\" \\"productsearch\\",\n \\"settings\\" {\n \\"personalisation\\" {\n \\"enablepersonalisation\\" true,\n \\"fields\\" \[\n \\"brand\\"\n ]\n },\n \\"context\\" {\n \\"recentobjects\\" \[\n {\n \\"typeofrecord\\" \\"klevu product\\",\n \\"records\\" \[\n {\n \\"id\\" \\"31366487507006\\"\n },\n {\n \\"id\\" \\"31366466633790\\"\n },\n {\n \\"id\\" \\"31366456311870\\"\n },\n {\n \\"id\\" \\"31366467944510\\"\n }\n ]\n }\n ]\n },\n \\"id\\" \\"productsearch\\",\n \\"typeofrecords\\" \[\n \\"klevu product\\"\n ],\n \\"limit\\" 5,\n \\"query\\" {\n \\"term\\" \\"short\\"\n },\n \\"fields\\" \[\n \\"id\\",\n \\"name\\",\n \\"brand\\"\n ]\n }\n }\n ],\n \\"context\\" {\n \\"apikeys\\" \[\n \\"klevu 156925593843210765\\"\n ]\n }\n}\n", "language" "json", "customlabel" "request body (json)" }, { "id" "8yg33te4jzfowp5yebmjh", "code" "\<?php\n\n$curl = curl init();\n\ncurl setopt array($curl, array(\n curlopt url => 'https //eucs15v2 ksearchnet com/cs/v2/search',\n curlopt returntransfer => true,\n curlopt encoding => '',\n curlopt maxredirs => 10,\n curlopt timeout => 0,\n curlopt followlocation => true,\n curlopt http version => curl http version 1 1,\n curlopt customrequest => 'post',\n curlopt postfields =>'{\n \\"recordqueries\\" \[\n {\n \\"settings\\" {\n \\"personalisation\\" {\n \\"enablepersonalisation\\" true,\n \\"fields\\" \[\n \\"brand\\"\n ]\n },\n \\"context\\" {\n \\"recentobjects\\" \[\n {\n \\"typeofrecord\\" \\"klevu product\\",\n \\"records\\" \[\n {\n \\"id\\" \\"31366487507006\\"\n },\n {\n \\"id\\" \\"31366466633790\\"\n },\n {\n \\"id\\" \\"31366456311870\\"\n },\n {\n \\"id\\" \\"31366467944510\\"\n }\n ]\n }\n ]\n },\n \\"id\\" \\"productsearch\\",\n \\"typeofrecords\\" \[\n \\"klevu product\\"\n ],\n \\"limit\\" 5,\n \\"query\\" {\n \\"term\\" \\"short\\"\n },\n \\"fields\\" \[\n \\"id\\",\n \\"name\\",\n \\"brand\\"\n ]\n }\n }\n ],\n \\"context\\" {\n \\"apikeys\\" \[\n \\"klevu 156925593843210765\\"\n ]\n }\n}\n',\n curlopt httpheader => array(\n 'content type application/json'\n ),\n));\n\n$response = curl exec($curl);\n\ncurl close($curl);\necho $response;\n", "language" "php", "customlabel" "" }, { "id" "wcdgtssqaxfiwklk2v174", "code" "var data = json stringify({\\"recordqueries\\" \[{\\"settings\\" {\\"personalisation\\" {\\"enablepersonalisation\\"\ true,\\"fields\\" \[\\"brand\\"]},\\"context\\" {\\"recentobjects\\" \[{\\"typeofrecord\\" \\"klevu product\\",\\"records\\" \[{\\"id\\" \\"31366487507006\\"},{\\"id\\" \\"31366466633790\\"},{\\"id\\" \\"31366456311870\\"},{\\"id\\" \\"31366467944510\\"}]}]},\\"id\\" \\"productsearch\\",\\"typeofrecords\\" \[\\"klevu product\\"],\\"limit\\" 5,\\"query\\" {\\"term\\" \\"short\\"},\\"fields\\" \[\\"id\\",\\"name\\",\\"brand\\"]}}],\\"context\\" {\\"apikeys\\" \[\\"klevu 156925593843210765\\"]}});\n\nvar xhr = new xmlhttprequest();\nxhr withcredentials = false;\n\nxhr addeventlistener(\\"readystatechange\\", function() {\n if(this readystate === 4) {\n console log(this responsetext);\n }\n});\n\nxhr open(\\"post\\", \\"https //eucs15v2 ksearchnet com/cs/v2/search\\");\nxhr setrequestheader(\\"content type\\", \\"application/json\\");\n\nxhr send(data);", "language" "javascript", "customlabel" "" }, { "id" "npw0nije j5r9i5w4bgn0", "code" "okhttpclient client = new okhttpclient() newbuilder()\n build();\nmediatype mediatype = mediatype parse(\\"application/json\\");\nrequestbody body = requestbody create(mediatype, \\"{\\\n \\\\\\"recordqueries\\\\\\" \[\\\n {\\\n \\\\\\"settings\\\\\\" {\\\n \\\\\\"personalisation\\\\\\" {\\\n \\\\\\"enablepersonalisation\\\\\\" true,\\\n \\\\\\"fields\\\\\\" \[\\\n \\\\\\"brand\\\\\\"\\\n ]\\\n },\\\n \\\\\\"context\\\\\\" {\\\n \\\\\\"recentobjects\\\\\\" \[\\\n {\\\n \\\\\\"typeofrecord\\\\\\" \\\\\\"klevu product\\\\\\",\\\n \\\\\\"records\\\\\\" \[\\\n {\\\n \\\\\\"id\\\\\\" \\\\\\"31366487507006\\\\\\"\\\n },\\\n {\\\n \\\\\\"id\\\\\\" \\\\\\"31366466633790\\\\\\"\\\n },\\\n {\\\n \\\\\\"id\\\\\\" \\\\\\"31366456311870\\\\\\"\\\n },\\\n {\\\n \\\\\\"id\\\\\\" \\\\\\"31366467944510\\\\\\"\\\n }\\\n ]\\\n }\\\n ]\\\n },\\\n \\\\\\"id\\\\\\" \\\\\\"productsearch\\\\\\",\\\n \\\\\\"typeofrecords\\\\\\" \[\\\n \\\\\\"klevu product\\\\\\"\\\n ],\\\n \\\\\\"limit\\\\\\" 5,\\\n \\\\\\"query\\\\\\" {\\\n \\\\\\"term\\\\\\" \\\\\\"short\\\\\\"\\\n },\\\n \\\\\\"fields\\\\\\" \[\\\n \\\\\\"id\\\\\\",\\\n \\\\\\"name\\\\\\",\\\n \\\\\\"brand\\\\\\"\\\n ]\\\n }\\\n }\\\n ],\\\n \\\\\\"context\\\\\\" {\\\n \\\\\\"apikeys\\\\\\" \[\\\n \\\\\\"klevu 156925593843210765\\\\\\"\\\n ]\\\n }\\\n}\\\n\\");\nrequest request = new request builder()\n url(\\"https //eucs15v2 ksearchnet com/cs/v2/search\\")\n method(\\"post\\", body)\n addheader(\\"content type\\", \\"application/json\\")\n build();\nresponse response = client newcall(request) execute();", "language" "java", "customlabel" "" }, { "id" "0ih7niekhhfml7cry51j ", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //eucs15v2 ksearchnet com/cs/v2/search',\n 'headers' {\n 'content type' 'application/json'\n },\n body json stringify({\\"recordqueries\\" \[{\\"settings\\" {\\"personalisation\\" {\\"enablepersonalisation\\"\ true,\\"fields\\" \[\\"brand\\"]},\\"context\\" {\\"recentobjects\\" \[{\\"typeofrecord\\" \\"klevu product\\",\\"records\\" \[{\\"id\\" \\"31366487507006\\"},{\\"id\\" \\"31366466633790\\"},{\\"id\\" \\"31366456311870\\"},{\\"id\\" \\"31366467944510\\"}]}]},\\"id\\" \\"productsearch\\",\\"typeofrecords\\" \[\\"klevu product\\"],\\"limit\\" 5,\\"query\\" {\\"term\\" \\"short\\"},\\"fields\\" \[\\"id\\",\\"name\\",\\"brand\\"]}}],\\"context\\" {\\"apikeys\\" \[\\"klevu 156925593843210765\\"]}})\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "language" "nodejs", "customlabel" "" } ], "selectedlanguageid" "wcdgtssqaxfiwklk2v174" }, "description" "this is an example how to utilize the recently visited products to personlised the search results ", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } try it here! known preferences if you have already built up a profile of your customer and would like to use what you know about them to promote certain results, you can use the boost object within each record query there are three ways the records can be boosted filter conditions keywords or phrases ids of specific records for example, let's say you have an online store with an area where customers can log in from your store's purchase history, you know that one customer is particularly interested in the brand 'kke' from your analytics data, you also know the same customer also looked at the product detail page of the product with id '31366487375934' many times finally, you have an area where customers can specify keywords of their interests, and this customer wrote 'comfortable' as a merchant with all of this information available, you can build up a profile about this customer the sample to the right shows how you would convey this information to klevu during a search to find out more about how boosting works with your existing merchandising rules, please read this article on how personalisation works https //help klevu com/support/solutions/articles/5000871357 how does it work { "tab" "examples", "url" "https //{{hostname}}/cs/v2/search", "name" "known preferences", "method" "post", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[], "bodydataparameters" \[ { "kind" "optional", "name" "filters", "type" "array", "description" "specify filter values to apply a boosting score to they key is the unique identifier of the attribute, eg color each of the values represents the value of that filter to boost, eg red or blue " }, { "kind" "optional", "name" "keywords", "type" "array", "description" "specify keywords or phrases to apply a boosting score to, for example \\"comfortable\\" " }, { "kind" "optional", "name" "records", "type" "array", "description" "specify the klevu id of any records to apply a boosting score to " }, { "kind" "optional", "name" "weight", "type" "number", "description" "the boosting value to be applied, a decimal between 0 999 please specify values above 1 for boosting the records up the rankings, and a value of 0 to 1 to de boost records down the rankings " } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "3xlvmt855lgkjoht0npxg", "code" "{\n \\"meta\\" {\n \\"qtime\\" 16,\n \\"responsecode\\" 200\n },\n \\"queryresults\\" \[\n {\n \\"id\\" \\"productsearch\\",\n \\"meta\\" {\n \\"qtime\\" 13,\n \\"noofresults\\" 5,\n \\"totalresultsfound\\" 104,\n \\"typeofsearch\\" \\"wildcard and\\",\n \\"offset\\" 0,\n \\"debugginginformation\\" {},\n \\"notificationcode\\" 1,\n \\"searchedterm\\" \\"short\\",\n \\"apikey\\" \\"klevu 156925593843210765\\",\n \\"ispersonalised\\" false\n },\n \\"records\\" \[\n {\n \\"name\\" \\"erika running short\\",\n \\"id\\" \\"31366431146046\\",\n \\"brand\\" \\"ksd\\"\n },\n {\n \\"name\\" \\"erika running short\\",\n \\"id\\" \\"31366431014974\\",\n \\"brand\\" \\"ksd\\"\n },\n {\n \\"name\\" \\"erika running short\\",\n \\"id\\" \\"31366431080510\\",\n \\"brand\\" \\"ksd\\"\n },\n {\n \\"name\\" \\"meteor workout short\\",\n \\"id\\" \\"31366465781822\\",\n \\"brand\\" \\"kke\\"\n },\n {\n \\"name\\" \\"hawkeye yoga short\\",\n \\"id\\" \\"31366465191998\\",\n \\"brand\\" \\"kke\\"\n }\n ],\n \\"filters\\" \[]\n }\n ]\n}", "language" "200", "customlabel" "" } ], "selectedlanguageid" "3xlvmt855lgkjoht0npxg" }, "examples" { "languages" \[ { "id" "jsu7dlyyj euh63ysp682", "code" "{\n \\"recordqueries\\" \[\n {\n \\"boost\\" {\n \\"filters\\" \[\n {\n \\"key\\" \\"brand\\",\n \\"values\\" \[\\"kke\\"],\n \\"weight\\" 200\n },\n {\n \\"key\\" \\"brand\\",\n \\"values\\" \[\\"mnh\\", \\"ksd\\"],\n \\"weight\\" 150\n }\n ],\n \\"keywords\\" \[\n {\n \\"phrase\\" \\"comfortable\\",\n \\"weight\\" 100\n }\n ],\n \\"records\\" \[\n {\n \\"id\\" \\"31366487375934\\",\n \\"weight\\" 300\n }\n ]\n },\n \\"id\\" \\"productsearch\\",\n \\"settings\\" {\n \\"query\\" {\n \\"term\\" \\"short\\"\n },\n \\"limit\\" 5,\n \\"typeofrecords\\" \[\n \\"klevu product\\"\n ],\n \\"fields\\" \[\n \\"id\\",\n \\"name\\",\n \\"brand\\"\n ]\n }\n }\n ],\n \\"context\\" {\n \\"apikeys\\" \[\n \\"klevu 156925593843210765\\"\n ]\n }\n}\n", "language" "json", "customlabel" "request body (json)" }, { "id" "8yg33te4jzfowp5yebmjh", "code" "\<?php\n\n$curl = curl init();\n\ncurl setopt array($curl, array(\n curlopt url => 'https //eucs15v2 ksearchnet com/cs/v2/search',\n curlopt returntransfer => true,\n curlopt encoding => '',\n curlopt maxredirs => 10,\n curlopt timeout => 0,\n curlopt followlocation => true,\n curlopt http version => curl http version 1 1,\n curlopt customrequest => 'post',\n curlopt postfields =>'{\n \\"recordqueries\\" \[\n {\n \\"boost\\" {\n \\"filters\\" \[\n {\n \\"key\\" \\"brand\\",\n \\"values\\" \[\\"kke\\"],\n \\"weight\\" 200\n },\n {\n \\"key\\" \\"brand\\",\n \\"values\\" \[\\"mnh\\", \\"ksd\\"],\n \\"weight\\" 150\n }\n ],\n \\"keywords\\" \[\n {\n \\"phrase\\" \\"comfortable\\",\n \\"weight\\" 100\n }\n ],\n \\"records\\" \[\n {\n \\"id\\" \\"31366487375934\\",\n \\"weight\\" 300\n }\n ]\n },\n \\"id\\" \\"productsearch\\",\n \\"settings\\" {\n \\"query\\" {\n \\"term\\" \\"short\\"\n },\n \\"limit\\" 5,\n \\"typeofrecords\\" \[\n \\"klevu product\\"\n ],\n \\"fields\\" \[\n \\"id\\",\n \\"name\\",\n \\"brand\\"\n ]\n }\n }\n ],\n \\"context\\" {\n \\"apikeys\\" \[\n \\"klevu 156925593843210765\\"\n ]\n }\n}\n',\n curlopt httpheader => array(\n 'content type application/json'\n ),\n));\n\n$response = curl exec($curl);\n\ncurl close($curl);\necho $response;\n", "language" "php", "customlabel" "" }, { "id" "wcdgtssqaxfiwklk2v174", "code" "var data = json stringify({\\"recordqueries\\" \[{\\"boost\\" {\\"filters\\" \[{\\"key\\" \\"brand\\",\\"values\\" \[\\"kke\\"],\\"weight\\" 200},{\\"key\\" \\"brand\\",\\"values\\" \[\\"mnh\\",\\"ksd\\"],\\"weight\\" 150}],\\"keywords\\" \[{\\"phrase\\" \\"comfortable\\",\\"weight\\" 100}],\\"records\\" \[{\\"id\\" \\"31366487375934\\",\\"weight\\" 300}]},\\"id\\" \\"productsearch\\",\\"settings\\" {\\"query\\" {\\"term\\" \\"short\\"},\\"limit\\" 5,\\"typeofrecords\\" \[\\"klevu product\\"],\\"fields\\" \[\\"id\\",\\"name\\",\\"brand\\"]}}],\\"context\\" {\\"apikeys\\" \[\\"klevu 156925593843210765\\"]}});\n\nvar xhr = new xmlhttprequest();\nxhr withcredentials = false;\n\nxhr addeventlistener(\\"readystatechange\\", function() {\n if(this readystate === 4) {\n console log(this responsetext);\n }\n});\n\nxhr open(\\"post\\", \\"https //eucs15v2 ksearchnet com/cs/v2/search\\");\nxhr setrequestheader(\\"content type\\", \\"application/json\\");\n\nxhr send(data);", "language" "javascript", "customlabel" "" }, { "id" "npw0nije j5r9i5w4bgn0", "code" "okhttpclient client = new okhttpclient() newbuilder()\n build();\nmediatype mediatype = mediatype parse(\\"application/json\\");\nrequestbody body = requestbody create(mediatype, \\"{\\\n \\\\\\"recordqueries\\\\\\" \[\\\n {\\\n \\\\\\"boost\\\\\\" {\\\n \\\\\\"filters\\\\\\" \[\\\n {\\\n \\\\\\"key\\\\\\" \\\\\\"brand\\\\\\",\\\n \\\\\\"values\\\\\\" \[\\\\\\"kke\\\\\\"],\\\n \\\\\\"weight\\\\\\" 200\\\n },\\\n {\\\n \\\\\\"key\\\\\\" \\\\\\"brand\\\\\\",\\\n \\\\\\"values\\\\\\" \[\\\\\\"mnh\\\\\\", \\\\\\"ksd\\\\\\"],\\\n \\\\\\"weight\\\\\\" 150\\\n }\\\n ],\\\n \\\\\\"keywords\\\\\\" \[\\\n {\\\n \\\\\\"phrase\\\\\\" \\\\\\"comfortable\\\\\\",\\\n \\\\\\"weight\\\\\\" 100\\\n }\\\n ],\\\n \\\\\\"records\\\\\\" \[\\\n {\\\n \\\\\\"id\\\\\\" \\\\\\"31366487375934\\\\\\",\\\n \\\\\\"weight\\\\\\" 300\\\n }\\\n ]\\\n },\\\n \\\\\\"id\\\\\\" \\\\\\"productsearch\\\\\\",\\\n \\\\\\"settings\\\\\\" {\\\n \\\\\\"query\\\\\\" {\\\n \\\\\\"term\\\\\\" \\\\\\"short\\\\\\"\\\n },\\\n \\\\\\"limit\\\\\\" 5,\\\n \\\\\\"typeofrecords\\\\\\" \[\\\n \\\\\\"klevu product\\\\\\"\\\n ],\\\n \\\\\\"fields\\\\\\" \[\\\n \\\\\\"id\\\\\\",\\\n \\\\\\"name\\\\\\",\\\n \\\\\\"brand\\\\\\"\\\n ]\\\n }\\\n }\\\n ],\\\n \\\\\\"context\\\\\\" {\\\n \\\\\\"apikeys\\\\\\" \[\\\n \\\\\\"klevu 156925593843210765\\\\\\"\\\n ]\\\n }\\\n}\\\n\\");\nrequest request = new request builder()\n url(\\"https //eucs15v2 ksearchnet com/cs/v2/search\\")\n method(\\"post\\", body)\n addheader(\\"content type\\", \\"application/json\\")\n build();\nresponse response = client newcall(request) execute();", "language" "java", "customlabel" "" }, { "id" "0ih7niekhhfml7cry51j ", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //eucs15v2 ksearchnet com/cs/v2/search',\n 'headers' {\n 'content type' 'application/json'\n },\n body json stringify({\\"recordqueries\\" \[{\\"boost\\" {\\"filters\\" \[{\\"key\\" \\"brand\\",\\"values\\" \[\\"kke\\"],\\"weight\\" 200},{\\"key\\" \\"brand\\",\\"values\\" \[\\"mnh\\",\\"ksd\\"],\\"weight\\" 150}],\\"keywords\\" \[{\\"phrase\\" \\"comfortable\\",\\"weight\\" 100}],\\"records\\" \[{\\"id\\" \\"31366487375934\\",\\"weight\\" 300}]},\\"id\\" \\"productsearch\\",\\"settings\\" {\\"query\\" {\\"term\\" \\"short\\"},\\"limit\\" 5,\\"typeofrecords\\" \[\\"klevu product\\"],\\"fields\\" \[\\"id\\",\\"name\\",\\"brand\\"]}}],\\"context\\" {\\"apikeys\\" \[\\"klevu 156925593843210765\\"]}})\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "language" "nodejs", "customlabel" "" } ], "selectedlanguageid" "wcdgtssqaxfiwklk2v174" }, "description" "this is an example how to boost products based on users preference ", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } try it here!