Skip to content

Commit 187ac8b

Browse files
authored
Merge pull request #72 from visenze/develop
[ES-9207] Release 4.1.0
2 parents f57c21f + ebf9582 commit 187ac8b

9 files changed

Lines changed: 495 additions & 7 deletions

File tree

README.md

Lines changed: 180 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ ViSenze's Javascript SDK provides accurate, reliable and scalable image search A
1515
- [1. Quickstart](#1-quickstart)
1616
- [1.1 Installation](#11-installation)
1717
- [1.2 Setup](#12-setup)
18+
- [1.2.1 Import and initialization](#121-import-and-initialization)
19+
- [1.2.2 Configure keys](#122-configure-keys)
1820
- [1.3 Demo](#13-demo)
1921
- [2. API](#2-api)
2022
- [2.1 Search by Image](#21-search-by-image)
2123
- [2.2 Recommendations](#22-recommendations)
24+
- [2.3 Multisearch](#23-multisearch)
25+
- [2.4 Multisearch Autocomplete](#24-multisearch-autocomplete)
2226
- [3. Search Results](#3-search-results)
2327
- [3.1 ErrorData](#31-errordata)
2428
- [3.2 ProductType](#32-producttype)
@@ -91,7 +95,7 @@ npm install visearch-javascript-sdk
9195

9296
```html
9397
<script type="text/javascript">
94-
!function(e,t,r,s,a){if(Array.isArray(a))for(var n=0;n<a.length;n++)o(e,t,r,s,a[n]);else o(e,t,r,s,a);function o(e,t,r,s,a){var n=e[a]||{};e[a]=n,n.q=n.q||[],n.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(e),n.q.push(t),n}},n.methods=["set","setKeys","sendEvent","sendEvents","productSearchByImage","productSearchById","productRecommendations","productSearchByIdByPost","productRecommendationsByPost","setUid","getUid","getSid","getLastQueryId","getSessionTimeRemaining","getDefaultTrackingParams","resetSession","resizeImage","generateUuid",];for(var o=0;o<n.methods.length;o++){var i=n.methods[o];n[i]=n.factory(i)}if(e.viInit)viInit(e,a);else{var c,d,u,f,g,m=(c=t,d=r,u=s,(f=c.createElement(d)).type="text/javascript",f.async=!0,f.src=u,(g=c.getElementsByTagName(d)[0]).parentNode.insertBefore(f,g),f);m.onload=function(){viInit(e,a)},m.onerror=function(){console.log("ViSearch Javascript SDK load fails")}}}}(window,document,"script","https://cdn.visenze.com/visearch/dist/js/visearch-4.0.2.min.js","visearch");
98+
!function(e,t,r,s,a){if(Array.isArray(a))for(var n=0;n<a.length;n++)o(e,t,r,s,a[n]);else o(e,t,r,s,a);function o(e,t,r,s,a){var n=e[a]||{};e[a]=n,n.q=n.q||[],n.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(e),n.q.push(t),n}},n.methods=["set","setKeys","sendEvent","sendEvents","productMultisearch","productMultisearchAutocomplete","productSearchByImage","productSearchById","productRecommendations","productSearchByIdByPost","productRecommendationsByPost","setUid","getUid","getSid","getLastQueryId","getSessionTimeRemaining","getDefaultTrackingParams","resetSession","resizeImage","generateUuid",];for(var o=0;o<n.methods.length;o++){var i=n.methods[o];n[i]=n.factory(i)}if(e.viInit)viInit(e,a);else{var c,d,u,f,g,m=(c=t,d=r,u=s,(f=c.createElement(d)).type="text/javascript",f.async=!0,f.src=u,(g=c.getElementsByTagName(d)[0]).parentNode.insertBefore(f,g),f);m.onload=function(){viInit(e,a)},m.onerror=function(){console.log("ViSearch Javascript SDK load fails")}}}}(window,document,"script","https://cdn.visenze.com/visearch/dist/js/visearch-4.1.0.min.js","visearch");
9599
</script>
96100
```
97101

@@ -283,6 +287,181 @@ visearch.productRecommendations(product_id, parameters, onResponse, onError);
283287
284288
> The request parameters for this API can be found at [ViSenze Documentation Hub](https://ref-docs.visenze.com/reference/search-by-image-api-1).
285289
290+
### 2.3 Multisearch
291+
292+
POST /product/multisearch
293+
294+
Multisearch can happen in four different ways - by text, url, id or File.
295+
296+
- Using text:
297+
298+
```javascript
299+
const parameters = {
300+
q: 'your-text-query'
301+
};
302+
303+
const onResponse = (response)=> {
304+
// TODO handle response
305+
}
306+
307+
const onError = (error)=> {
308+
// TODO handle error
309+
}
310+
311+
visearch.productMultisearch(parameters, onResponse, onError);
312+
```
313+
314+
- Using image id:
315+
316+
```javascript
317+
const parameters = {
318+
im_id: 'your-image-id'
319+
};
320+
321+
const onResponse = (response)=> {
322+
// TODO handle response
323+
}
324+
325+
const onError = (error)=> {
326+
// TODO handle error
327+
}
328+
329+
visearch.productMultisearch(parameters, onResponse, onError);
330+
```
331+
332+
- Using image url:
333+
334+
```javascript
335+
const parameters = {
336+
im_url: 'your-image-url'
337+
};
338+
339+
const onResponse = (response)=> {
340+
// TODO handle response
341+
}
342+
343+
const onError = (error)=> {
344+
// TODO handle error
345+
}
346+
347+
visearch.productMultisearch(parameters, onResponse, onError);
348+
```
349+
350+
- Using image file:
351+
352+
```html
353+
<form>
354+
Upload image: <input type="file" id="fileUpload" name="fileInput"><br>
355+
<input type="submit" value="Submit">
356+
</form>
357+
```
358+
359+
```javascript
360+
const parameters = {
361+
image: document.getElementById('fileUpload')
362+
};
363+
364+
const onResponse = (response)=> {
365+
// TODO handle response
366+
}
367+
368+
const onError = (error)=> {
369+
// TODO handle error
370+
}
371+
372+
visearch.productMultisearch(parameters, onResponse, onError);
373+
```
374+
375+
> The request parameters for this API can be found at [ViSenze Documentation Hub](https://ref-docs.visenze.com/reference/multimodal-api).
376+
377+
### 2.4 Multisearch Autocomplete
378+
379+
POST /product/multisearch/autocomplete
380+
381+
Multisearch autocomplete can happen in four different ways - by text, url, id or File.
382+
383+
- Using text:
384+
385+
```javascript
386+
const parameters = {
387+
q: 'your-text-query'
388+
};
389+
390+
const onResponse = (response)=> {
391+
// TODO handle response
392+
}
393+
394+
const onError = (error)=> {
395+
// TODO handle error
396+
}
397+
398+
visearch.productMultisearchAutocomplete(parameters, onResponse, onError);
399+
```
400+
401+
- Using image id:
402+
403+
```javascript
404+
const parameters = {
405+
im_id: 'your-image-id'
406+
};
407+
408+
const onResponse = (response)=> {
409+
// TODO handle response
410+
}
411+
412+
const onError = (error)=> {
413+
// TODO handle error
414+
}
415+
416+
visearch.productMultisearchAutocomplete(parameters, onResponse, onError);
417+
```
418+
419+
- Using image url:
420+
421+
```javascript
422+
const parameters = {
423+
im_url: 'your-image-url'
424+
};
425+
426+
const onResponse = (response)=> {
427+
// TODO handle response
428+
}
429+
430+
const onError = (error)=> {
431+
// TODO handle error
432+
}
433+
434+
visearch.productMultisearchAutocomplete(parameters, onResponse, onError);
435+
```
436+
437+
- Using image file:
438+
439+
```html
440+
<form>
441+
Upload image: <input type="file" id="fileUpload" name="fileInput"><br>
442+
<input type="submit" value="Submit">
443+
</form>
444+
```
445+
446+
```javascript
447+
const parameters = {
448+
image: document.getElementById('fileUpload')
449+
};
450+
451+
const onResponse = (response)=> {
452+
// TODO handle response
453+
}
454+
455+
const onError = (error)=> {
456+
// TODO handle error
457+
}
458+
459+
visearch.productMultisearchAutocomplete(parameters, onResponse, onError);
460+
```
461+
462+
> The request parameters for this API can be found at [ViSenze Documentation Hub](https://ref-docs.visenze.com/reference/multimodal-api).
463+
464+
286465
## 3. Search Results
287466
288467
Javascript does not contain type definitions and the REST API response for all our APIs will instead just convert straight into javascript objects. Here are some of the [API](#2-api)'s response object's keys to take note of:

examples/js/snippet.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
'setKeys',
4545
'sendEvent',
4646
'sendEvents',
47+
'productMultisearch',
48+
'productMultisearchAutocomplete',
4749
'productSearchByImage',
4850
'productSearchById',
4951
'productRecommendations',

0 commit comments

Comments
 (0)