Skip to content

Commit ac5f9fc

Browse files
committed
Deprecate useFuzzyMatch in favor of setFuzzyMatch. Set default value to "auto"
1 parent 49a293b commit ac5f9fc

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ client.setSuggestionsSize(20);
7171

7272
#### Search with fuzzy matching
7373
```js
74-
// Enable/disable fuzzy matching for typo tolerance (default "true")
75-
client.useFuzzyMatch(false);
74+
// Enable/disable fuzzy matching. Possible values true/false/"auto" (default: "auto")
75+
client.setFuzzyMatch(false);
7676
```
7777

7878
#### Set JSON Web Token (for authentication)
@@ -149,10 +149,18 @@ client.removeCustomFieldFilter('city');
149149
```
150150

151151
#### Manage paging
152+
Set page number, page size and sorting parameters. It's possible to order results by:
153+
- relevance (descending)
154+
- date (ascending or descending)
155+
- custom field value (ascending or descending. E.g. *custom_fields.price*)
152156
```js
153157
// Defaults: page "1", pageSize "10", sortBy "relevance", sortOrder "desc"
154158
client.setPaging(page, pageSize, sortBy, sortOrder);
159+
```
160+
161+
Other functions.
155162

163+
```js
156164
// Next page (call search function to fetch results)
157165
client.nextPage();
158166

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ var client = function(sitekey) {
6666
*/
6767
this.getSettings = function() { return this.settings.getSettings(); }
6868
this.setLanguage = function(lang) { this.settings.setLanguage(lang); }
69-
this.useFuzzyMatch = function(use) { this.settings.useFuzzyMatch(use); }
7069
this.setCategoryFilters = function(categories) { this.settings.setCategoryFilters(categories); }
7170
this.addCustomFieldFilter = function(fieldName, value) { this.settings.addCustomFieldFilter(fieldName, value); }
7271
this.removeCustomFieldFilter = function(fieldName, value) { this.settings.removeCustomFieldFilter(fieldName, value); }
@@ -84,7 +83,11 @@ var client = function(sitekey) {
8483
this.setPersonalizationEvents = function(events) { this.settings.setPersonalizationEvents(events); }
8584
this.setFilterObject = function(filter) { this.settings.setFilterObject(filter); }
8685
this.setShuffleAndLimitTo = function(shuffleAndLimitTo) { this.settings.setShuffleAndLimitTo(shuffleAndLimitTo); }
86+
this.setFuzzyMatch = function(fuzzy) { this.settings.setFuzzyMatch(fuzzy); }
8787
//this.hitClicked = function(docid, position) { sendClickHit(this.sitekey, this.settings.getSettings().keyword, docid, position); }
88+
89+
// Deprecated
90+
this.useFuzzyMatch = function(use) { this.settings.setFuzzyMatch(use); }
8891
}
8992

9093
module.exports = client;

src/settings.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var settings = function() {
44
this.settings = {
55
keyword: '*',
66
callback: null,
7-
fuzzy: true,
7+
fuzzy: 'auto',
88
paging: {
99
page: 1,
1010
pageSize: 10,
@@ -44,7 +44,10 @@ var settings = function() {
4444
this.settings.lang = language;
4545
}
4646

47-
this.useFuzzyMatch = function(fuzzy) {
47+
this.setFuzzyMatch = function(fuzzy) {
48+
if (fuzzy !== true && fuzzy !== false && fuzzy !== 'auto') {
49+
throw "fuzzy matching can be true, false, or 'auto'";
50+
}
4851
this.settings.fuzzy = fuzzy;
4952
}
5053

0 commit comments

Comments
 (0)