Skip to content

Commit 3d4134b

Browse files
add (props): vectorDataField and candidates for SearchBox / ReactiveList
1 parent fc28f52 commit 3d4134b

File tree

4 files changed

+112
-49
lines changed

4 files changed

+112
-49
lines changed

content/docs/reactivesearch/react/result/reactivelist.md

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Example uses:
3939
componentId="SearchResult"
4040
compoundClause="filter"
4141
dataField="ratings"
42+
vectorDataField="vector_data" # Only one of dataField or vectorDataField is needed
4243
pagination={false}
4344
paginationAt="bottom"
4445
pages={5}
@@ -47,11 +48,9 @@ Example uses:
4748
loader="Loading Results.."
4849
showResultStats={true}
4950
renderItem={res => <div>{res.title}</div>}
50-
renderResultStats={function(stats) {
51-
return `Showing ${stats.displayedResults} of total ${stats.numberOfResults} in ${
52-
stats.time
53-
} ms`;
54-
}}
51+
renderResultStats={stats => `Showing ${stats.displayedResults} of total ${stats.numberOfResults} in ${
52+
stats.time
53+
} ms`}
5554
highlight={true}
5655
highlightConfig={{
5756
'pre_tags': ['<mark>'],
@@ -124,9 +123,18 @@ Accepts the following properties:
124123

125124
| Type | Optional |
126125
|------|----------|
127-
| `String` | No |
126+
| `String` | Yes |
128127

129128
data field to be connected to the component's UI view. It is useful for providing a sorting context.
129+
130+
### vectorDataField
131+
132+
| Type | Optional |
133+
|------|----------|
134+
| `String` | Yes |
135+
136+
vector data field to query for retrieving hits for the component's UI view. This is used when applying kNN search. Introduced in v4.3.0.
137+
130138
### distinctField
131139

132140
| Type | Optional |
@@ -147,7 +155,7 @@ You can read more about it over [here](https://www.elastic.co/guide/en/elasticse
147155
148156
> It is possible to override this query by providing `defaultQuery`.
149157
150-
> Note: This prop has been marked as deprecated starting v3.18.0. Please use the `distinctField` prop instead.
158+
> Note: This prop has been marked as deprecated starting v3.18.0. Please use the `distinctField` prop instead.
151159
152160
### aggregationSize
153161
To set the number of buckets to be returned by aggregations.
@@ -247,6 +255,15 @@ accepts the label of the desired sort option to set default sort value from give
247255
| `Number` | Yes |
248256

249257
number of results to show per view. Defaults to 10.
258+
259+
### candidates
260+
261+
| Type | Optional |
262+
|------|----------|
263+
| `Number` | Yes |
264+
265+
number of candidate values (aka k) to retrieve for kNN search. This is used with kNN search.
266+
250267
### loader
251268

252269
| Type | Optional |
@@ -307,25 +324,23 @@ Read more about it [here](/docs/reactivesearch/react/advanced/customqueries/#whe
307324
returns a list element object to be rendered based on the `res` data object. This callback function prop is called for each data item rendered in the **ReactiveList** component's view. For example,
308325
```jsx
309326
renderItem = {
310-
function(res) {
311-
return (
312-
<a className="full_row single-record single_record_for_clone" key={res._id}>
313-
<div className="text-container full_row" style={{ paddingLeft: '10px' }}>
314-
<div className="text-head text-overflow full_row">
315-
<span className="text-head-info text-overflow">
316-
{res.name ? res.name : ''} - {res.brand ? res.brand : ''}
317-
</span>
318-
<span className="text-head-city">{res.brand ? res.brand : ''}</span>
319-
</div>
320-
<div className="text-description text-overflow full_row">
321-
<ul className="highlight_tags">
322-
{res.price ? `Priced at $${res.price}` : 'Free Test Drive'}
323-
</ul>
324-
</div>
327+
res => (
328+
<a className="full_row single-record single_record_for_clone" key={res._id}>
329+
<div className="text-container full_row" style={{ paddingLeft: '10px' }}>
330+
<div className="text-head text-overflow full_row">
331+
<span className="text-head-info text-overflow">
332+
{res.name ? res.name : ''} - {res.brand ? res.brand : ''}
333+
</span>
334+
<span className="text-head-city">{res.brand ? res.brand : ''}</span>
325335
</div>
326-
</a>
327-
);
328-
},
336+
<div className="text-description text-overflow full_row">
337+
<ul className="highlight_tags">
338+
{res.price ? `Priced at $${res.price}` : 'Free Test Drive'}
339+
</ul>
340+
</div>
341+
</div>
342+
</a>
343+
)
329344
};
330345
```
331346
### render
@@ -377,11 +392,9 @@ renders custom result stats using a callback function that takes `stats` object
377392
Total number of promoted results found
378393
```jsx
379394
renderResultStats = {
380-
function(stats) {
381-
return `Showing ${stats.displayedResults} of total ${stats.numberOfResults} in ${
382-
stats.time
383-
} ms`;
384-
},
395+
stats => `Showing ${stats.displayedResults} of total ${stats.numberOfResults} in ${
396+
stats.time
397+
} ms`
385398
};
386399
```
387400
### renderNoResults
@@ -427,7 +440,7 @@ renderPagination={({ pages, totalPages, currentPage, setPage, setSize }) => {
427440
</select>
428441
);
429442
return selectPage;
430-
}
443+
}}
431444
```
432445
### renderExport
433446

@@ -445,11 +458,13 @@ renderExport={
445458
({
446459
triggerExportCSV,
447460
triggerExportJSON
448-
}) => (<div> Custom Export
449-
<button onClick={triggerExportCSV}>CSV 🔢</button>
450-
<button onClick={triggerExportJSON}>JSON ❤️</button>
451-
</div>)
452-
}
461+
}) => (
462+
<div> Custom Export
463+
<button onClick={triggerExportCSV}>CSV 🔢</button>
464+
<button onClick={triggerExportJSON}>JSON ❤️</button>
465+
</div>
466+
)
467+
}
453468
```
454469
### onData
455470

@@ -596,16 +611,14 @@ Read more about it [here](/docs/reactivesearch/react/theming/classnameinjection/
596611
className="custom-class"
597612
style={{"paddingBottom": "10px"}}
598613
renderItem={
599-
function(res) {
600-
return(
601-
<div>
602-
{ res.data }
603-
</div>
604-
)
605-
}
614+
res => (
615+
<div>
616+
{ res.data }
617+
</div>
618+
)
606619
}
607620
onQueryChange={
608-
function(prevQuery, nextQuery) {
621+
(prevQuery, nextQuery) => {
609622
// use the query with other js code
610623
console.log('prevQuery', prevQuery);
611624
console.log('nextQuery', nextQuery);

content/docs/reactivesearch/react/search/searchbox.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Example uses:
4747
"weight": 3
4848
}
4949
]}
50+
vectorDataField="vector_data" # Only one of dataField or vectorDataField is needed
5051
title="Search"
5152
mode="tag" // accepts either of 'select' or 'tag', defaults to 'select'
5253
defaultValue="Songwriting"
@@ -182,8 +183,13 @@ type DataField = {
182183
```
183184
database field(s) to be queried against. Accepts an Array in addition to String, useful for applying search across multiple fields. Check examples at [here](/docs/search/reactivesearch-api/reference/#datafield).
184185

185-
> Note:
186-
The `dataField` property as `DataField` object is only available for ReactiveSearch version >= `v3.21.0` and Appbase version `v7.47.0`.
186+
### vectorDataField
187+
188+
| Type | Optional |
189+
|------|----------|
190+
| `String` | Yes |
191+
192+
vector data field to query for retrieving hits for the component's UI view. This is used when applying kNN search. Introduced in v3.4.0.
187193

188194
### size
189195

@@ -192,6 +198,15 @@ The `dataField` property as `DataField` object is only available for ReactiveSea
192198
| `Number` | Yes |
193199

194200
number of suggestions to show. Defaults to `10`.
201+
202+
### candidates
203+
204+
| Type | Optional |
205+
|------|----------|
206+
| `Number` | Yes |
207+
208+
number of candidate values (aka k) to retrieve for kNN search. This is used with kNN search for populating the suggestions view.
209+
195210
### distinctField
196211

197212
| Type | Optional |

content/docs/reactivesearch/vue/result/ReactiveList.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Example uses:
4040
componentId="SearchResult"
4141
compoundClause="filter"
4242
dataField="ratings"
43+
vectorDataField="vector_data" # Only one of dataField or vectorDataField is needed
4344
paginationAt="bottom"
4445
loader="Loading Results.."
4546
prevLabel="Prev"
@@ -48,6 +49,7 @@ Example uses:
4849
:pagination="false"
4950
:pages="5"
5051
:size="10"
52+
:candidates="10"
5153
:showResultStats="true"
5254
:react="{ and: ['CitySensor', 'SearchSensor'] }"
5355
:endpoint="{
@@ -108,10 +110,18 @@ Accepts the following properties:
108110

109111
| Type | Optional |
110112
|------|----------|
111-
| `String` | No |
113+
| `String` | Yes |
112114

113115
data field to be connected to the component's UI view. It is useful for providing a **sorting** context i.e. results would be sorted based on the `dataField`.
114116

117+
### vectorDataField
118+
119+
| Type | Optional |
120+
|------|----------|
121+
| `String` | Yes |
122+
123+
vector data field to query for retrieving hits for the component's UI view. This is used when applying kNN search. Introduced in v4.3.0.
124+
115125
### aggregationSize
116126
To set the number of buckets to be returned by aggregations.
117127

@@ -204,6 +214,15 @@ accepts the label of the desired sort option to set default sort value from give
204214
| `Number` | Yes |
205215

206216
number of results to show per view. Defaults to 10.
217+
218+
### candidates
219+
220+
| Type | Optional |
221+
|------|----------|
222+
| `Number` | Yes |
223+
224+
number of candidate values (aka k) to retrieve for kNN search. This is used with kNN search.
225+
207226
### loader
208227

209228
| Type | Optional |

content/docs/reactivesearch/vue/search/SearchBox.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ Example uses:
5555
'weight': 3
5656
},
5757
]"
58+
vectorDataField="vector_data" # Only one of dataField or vectorDataField is needed
5859
:defaultSuggestions="[
5960
{ label: 'Songwriting', value: 'Songwriting' },
6061
{ label: 'Musicians', value: 'Musicians' },
6162
]"
6263
:fuzziness="0"
6364
:size="10"
65+
:candidates="10" # used with vectorDataField for kNN retrieving
6466
:debounce="100"
6567
:react="{
6668
and: ['CategoryFilter', 'SearchFilter']
@@ -205,8 +207,13 @@ type DataField = {
205207
```
206208
database field(s) to be queried against. Accepts an Array in addition to String, useful for applying search across multiple fields. Check examples at [here](/docs/search/reactivesearch-api/reference/#datafield).
207209

208-
> Note:
209-
> 1. The `dataField` property as `DataField` object is only available for ReactiveSearch version >= `v3.0.0` and Appbase version `v7.47.0`.
210+
### vectorDataField
211+
212+
| Type | Optional |
213+
|------|----------|
214+
| `String` | Yes |
215+
216+
vector data field to query for retrieving hits for the component's UI view. This is used when applying kNN search. Introduced in v3.4.0.
210217

211218
### size
212219

@@ -215,6 +222,15 @@ database field(s) to be queried against. Accepts an Array in addition to String,
215222
| `Number` | Yes |
216223

217224
number of suggestions to show. Defaults to `10`.
225+
226+
### candidates
227+
228+
| Type | Optional |
229+
|------|----------|
230+
| `Number` | Yes |
231+
232+
number of candidate values (aka k) to retrieve for kNN search. This is used with kNN search for populating the suggestions view.
233+
218234
### excludeFields
219235

220236
| Type | Optional |

0 commit comments

Comments
 (0)