-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.html
94 lines (88 loc) · 3.47 KB
/
app.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<html>
<head>
<title>Search App</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.24.3/css/uikit.min.css" />
<style>
.title{
width:20%;
}
.description{
width:80%;
}
</style>
<script src="https://cloudboost.io/js-sdk/cloudboost.min.js"></script>
<script src='http://code.jquery.com/jquery-1.11.2.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.24.3/js/uikit.min.js"></script>
</head>
<body>
<div class="uk-grid" style="padding:10px;">
<div class="uk-width-1-3" style="border-right:medium solid #555;">
<br>
<article class="uk-article">
<h2>CloudSearch</h2>
<span>CB.CloudSearch( tableName, [CB.SearchQuery], [CB.SearchFilter])</span>
<h2>SearchQuery</h2>
<span>SearchQuery.searchOn( columns, queryText, [fuzziness], [all_words], [match_percent], [priority] )</span>
<dl class="uk-description-list-horizontal">
<dt>fuzziness</dt>
<dd>Can be set to 0, 1, 2. Default is 0. This parameter sets the fuzziness on search.</dd>
<dt>all words</dt>
<dd>Can take only value - true. If set the search will contain all the words in query. For example, If your search query is "Brown Fox". Results will contain both the words "Brown" AND "Fox".</dd>
<dt>match_percent</dt>
<dd>Can take only value - %. For ex : "75%". If set the search will return all the results which matches 75%.</dd>
<dt>priority</dt>
<dd>If set this query will have a higer priority over all other queries.</dd>
</dl>
<hr class="uk-article-divider">
<a href="https://docs.cloudboost.io/#CloudSearch">Click here</a> for detail documentation of cloudsearch.
</article>
</div>
<div class="uk-width-2-3">
<br>
<div>
<form id="searchForm" method="post" action="" class="uk-form">
<fieldset data-uk-margin>
<input id="term" type="search" placeholder="Query Text" style="width:40%;">
<input id="fuzziness" type="number" min="0" max="2" placeholder="Fuzziness">
<label><input id="all-words" type="checkbox">All Words</label>
<input id="match-percent" type="number" min="0" max="100" placeholder="Match in %">
<button type="submit" name="search" class="uk-button" style="width:9%;">Search</button>
</fieldset>
</form>
</div>
<br>
<hr>
<div style="text-align:center;">
<strong>Search Result</strong>
</div>
<hr>
<br>
<div>
<table id="resultlist" style="width:100%;" class="uk-table uk-table-striped">
</table>
</div>
</div>
</div>
<script>
CB.CloudApp.init('searchexp', 'xbEqb0LfoktTXag/29bpsg==');
var cs;
$("#searchForm").submit(function() {
$("#resultlist").empty();
$("#resultlist").append("<tr><th class='title'>Title</th><th class='description'>Description</th></tr>");
cs = new CB.CloudSearch('Collection');
cs.searchQuery = new CB.SearchQuery();
cs.searchQuery.searchOn(['title', 'description'], $("#term").val(), $("#fuzziness").val(), $("#all-words").val(), $("#match-percent").val());
cs.search({
success: function(list) {
for (i = 0; i < list.length; i++) {
$("#resultlist").append("<tr><td class='title'>"+list[i].get('title')+"</td><td class='description'>"+list[i].get('description')+"</td></tr>");
}
}, error: function(error) {
console.log(error);
}
});
return false;
});
</script>
</body>
</html>