@@ -70,11 +70,12 @@ client.suggestions('a', callback);
7070client .setSuggestionsSize (20 );
7171```
7272
73- #### Fetch custom field autocompletion
73+ #### Custom field autocompletion
7474Custom fields autocomplete can be used for predictive search. For example, product names or categories can be
7575suggested as the keyword is being typed in.
7676``` js
77- // Fetch custom field values starting with a specific prefix. In this example, results could be "adidas, apple, azure"
77+ // Fetch custom field values starting with a specific prefix In this example, fetch records
78+ // starting with *a* from the *custom_fields.brand* field. Results could be "adidas, apple, azure"
7879client .autocomplete (' custom_fields.brand' , ' a' , callback);
7980```
8081
@@ -86,8 +87,29 @@ client.setAutocompleteSize(20);
8687
8788#### Search with fuzzy matching
8889``` js
89- // Enable/disable fuzzy matching. Possible values true/false/"auto" (default: "auto")
90- client .setFuzzyMatch (false );
90+ // Control fuzzy matching used for typo-tolerance
91+ // Possible values true/false/"auto" (default: "auto")
92+ client .setFuzzyMatch (false );
93+ ```
94+
95+ ### Pagination
96+ Set page number, page size and sorting parameters. It's possible to order results by:
97+ - relevance (descending)
98+ - date (ascending or descending)
99+ - custom field value (ascending or descending. E.g. * custom_fields.price* )
100+ ``` js
101+ // Defaults: page "1", pageSize "10", sortBy "relevance", sortOrder "desc"
102+ client .setPaging (page, pageSize, sortBy, sortOrder);
103+ ```
104+
105+ Other functions.
106+
107+ ``` js
108+ // Next page (call search function to fetch results)
109+ client .nextPage ();
110+
111+ // Previous page
112+ client .previousPage ();
91113```
92114
93115### Search analytics
@@ -99,8 +121,8 @@ client.sendStatsEvent('search', keyword, {numberOfResults: n});
99121```
100122
101123#### Send click event to analytics
102- When a search results is clicked, send the event to your AddSearch Analytics Dashboard. Information on clicks is used
103- in your statistics and in the self-learning search algorithm.
124+ When a search results is clicked, send the event to your AddSearch Analytics Dashboard. Click information is shown
125+ in your statistics and used by the self-learning search algorithm.
104126``` js
105127// documentId is the 32-character long id that is part of each hit in search results.
106128// position is the position of the document that was clicked, the first result being 1
@@ -116,7 +138,8 @@ client.setStatsSessionId(id);
116138```
117139
118140#### Collect search events automatically
119- Not recommended. For example, search-as-you-type implementation would fire a statistics event after every keystroke
141+ Send search events automatically. Not recommended in search-as-you-type implementations, as every keystroke
142+ would fire a statistics event
120143``` js
121144// Control whether search queries are sent to your AddSearch Analytics Dashboard automatically or not (default: false)
122145client .setCollectAnalytics (true );
@@ -126,7 +149,7 @@ client.setCollectAnalytics(true);
126149
127150#### Define language filter
128151``` js
129- // Documents in specific language (e.g. "en" or "de")
152+ // Fetch documents in specific language (e.g. "en" or "de")
130153client .setLanguage (' en' );
131154```
132155
@@ -191,24 +214,17 @@ client.setFilterObject(filter);
191214client .setResultType (' organic' );
192215```
193216
194- ### Pagination
195- Set page number, page size and sorting parameters. It's possible to order results by:
196- - relevance (descending)
197- - date (ascending or descending)
198- - custom field value (ascending or descending. E.g. * custom_fields.price* )
217+ ### Facets
199218``` js
200- // Defaults: page "1", pageSize "10", sortBy "relevance", sortOrder "desc"
201- client .setPaging (page, pageSize, sortBy, sortOrder);
219+ // Declare fields for faceting. Number of hits found from
220+ // these fields will be returned
221+ client .addFacetField (' category' );
222+ client .addFacetField (' custom_fields.genre' );
202223```
203-
204- Other functions.
205-
224+ By default, 10 facets with most hits are returned per field.
225+ Use the following function to get more or less facets.
206226``` js
207- // Next page (call search function to fetch results)
208- client .nextPage ();
209-
210- // Previous page
211- client .previousPage ();
227+ client .setNumberOfFacets (20 );
212228```
213229
214230### Personalization
@@ -244,20 +260,6 @@ client.setPersonalizationEvents(events);
244260client .setJWT (token);
245261```
246262
247-
248- #### Facets
249- ``` js
250- // Declare fields for faceting. Number of hits found from
251- // these fields will be returned
252- client .addFacetField (' category' );
253- client .addFacetField (' custom_fields.genre' );
254- ```
255- By default, 10 facets with most hits are returned per field.
256- Use the following function to get more or less facets.
257- ``` js
258- client .setNumberOfFacets (20 );
259- ```
260-
261263## Supported web browsers and node.js versions
262264The client is tested on
263265- Chrome
0 commit comments