Skip to content

Commit 2388ff1

Browse files
authored
RI-7360: Add proper bikes collection saved queries (#4990)
1 parent d9e65af commit 2388ff1

File tree

3 files changed

+111
-56
lines changed

3 files changed

+111
-56
lines changed

redisinsight/ui/src/pages/vector-search/saved-queries/SavedQueriesScreen.spec.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,29 @@ describe('SavedQueriesScreen', () => {
5656

5757
// Check that preset queries are rendered for bikes index
5858
expect(
59-
screen.getByText('Search for "Nord" bikes ordered by price'),
59+
screen.getByText("Run a vector search for 'Comfortable commuter bike'"),
6060
).toBeInTheDocument()
6161
expect(
62-
screen.getByText('Find road alloy bikes under 20kg'),
62+
screen.getByText(
63+
"Run a vector search for 'Commuter bike for people over 60'",
64+
),
65+
).toBeInTheDocument()
66+
expect(
67+
screen.getByText(
68+
"Run a vector search for 'Female specific mountain bike'",
69+
),
70+
).toBeInTheDocument()
71+
expect(
72+
screen.getByText(
73+
"Run a vector search for 'Female specific mountain bike' for bikes type 'Mountain bikes' and with price between $3500 and $3500",
74+
),
6375
).toBeInTheDocument()
6476
})
6577

6678
it('should render insert buttons for each query', () => {
6779
renderComponent()
6880
const insertButtons = screen.getAllByText('Insert')
69-
expect(insertButtons).toHaveLength(2)
81+
expect(insertButtons).toHaveLength(4)
7082
})
7183

7284
it('should select the first index by default', () => {
@@ -93,7 +105,9 @@ describe('SavedQueriesScreen', () => {
93105
const firstInsertButton = screen.getAllByText('Insert')[0]
94106
fireEvent.click(firstInsertButton)
95107
expect(mockOnQueryInsert).toHaveBeenCalledWith(
96-
'FT.SEARCH idx:bikes_vss "@brand:Nord" SORTBY price ASC',
108+
expect.stringContaining(
109+
'FT.SEARCH idx:bikes_vss \"*=>[KNN 3 @description_embeddings $my_blob AS score ]\" RETURN 4 score brand type description PARAMS 2 my_blob \"\\xecNN<\\xec\\xc78=\\`',
110+
),
97111
)
98112
})
99113

@@ -102,7 +116,9 @@ describe('SavedQueriesScreen', () => {
102116
const secondInsertButton = screen.getAllByText('Insert')[1]
103117
fireEvent.click(secondInsertButton)
104118
expect(mockOnQueryInsert).toHaveBeenCalledWith(
105-
'FT.SEARCH idx:bikes_vss "@material:{alloy} @weight:[0 20]"',
119+
expect.stringContaining(
120+
'FT.SEARCH idx:bikes_vss \"*=>[KNN 3 @description_embeddings $my_blob AS score ]\" PARAMS 2 my_blob \"A=\\xe1\\xbb\\x8a\\xad\\x9b<&7R',
121+
),
106122
)
107123
})
108124

redisinsight/ui/src/pages/vector-search/saved-queries/SavedQueriesScreen.tsx

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// This is because of the long vec value in the data
2-
/* eslint-disable max-len */
31
import React, { useState, useMemo, useEffect } from 'react'
42

53
import { Title } from 'uiSrc/components/base/text'
@@ -25,64 +23,18 @@ import NoDataMessage from '../components/no-data-message/NoDataMessage'
2523
import { QueryCard } from './QueryCard'
2624
import { IndexSelect } from './IndexSelect'
2725
import { NoDataMessageKeys } from '../components/no-data-message/data'
26+
import { savedQueries } from './saved-queries'
2827

2928
const mockSavedIndexes: SavedIndex[] = [
3029
{
3130
value: PresetDataType.BIKES,
3231
tags: [FieldTypes.TAG, FieldTypes.TEXT, FieldTypes.VECTOR],
33-
queries: [
34-
{
35-
label: 'Search for "Nord" bikes ordered by price',
36-
value: 'FT.SEARCH idx:bikes_vss "@brand:Nord" SORTBY price ASC',
37-
},
38-
{
39-
label: 'Find road alloy bikes under 20kg',
40-
value: 'FT.SEARCH idx:bikes_vss "@material:{alloy} @weight:[0 20]"',
41-
},
42-
],
32+
queries: savedQueries[PresetDataType.BIKES],
4333
},
4434
{
4535
value: PresetDataType.MOVIES,
4636
tags: [FieldTypes.TAG, FieldTypes.TEXT, FieldTypes.VECTOR],
47-
queries: [
48-
{
49-
label: 'I want a fun animated movie about toys and friendship',
50-
value:
51-
'FT.SEARCH idx:movies_vss "*=>[KNN 3 @embedding $vec AS score]" ' +
52-
`PARAMS 2 vec ${String.raw`"\x9a\x99\x19\x3f\xcd\xcc\xcc\x3d\x9a\x99\x4c\x3f\x9a\x99\x33\x3e\x9a\x99\x33\x3f\xcd\xcc\x66\x3e\xcd\xcc\xcc\x3d\xcd\xcc\x4c\x3e"`} ` +
53-
'SORTBY score ' +
54-
'RETURN 3 title plot score ' +
55-
'DIALECT 2',
56-
},
57-
{
58-
label: 'A feel-good film about music and students',
59-
value:
60-
'FT.SEARCH idx:movies_vss "@genres:{Music} =>[KNN 5 @embedding $vec AS score]" ' +
61-
`PARAMS 2 vec ${String.raw`"\x9a\x99\x1d\x3e\xcd\xcc\x4c\xbd\x9a\x99\x99\x3e\x9a\x99\x19\x3e\x9a\x99\x19\xbe\x9a\x99\x1d\x3e\xcd\xcc\x0c\x3e\x9a\x99\xf1\xbc"`} ` +
62-
'SORTBY score ' +
63-
'RETURN 3 title genres score ' +
64-
'DIALECT 2',
65-
},
66-
{
67-
label: 'Find classic musical rebellion films from the 90s',
68-
value:
69-
'FT.SEARCH idx:movies_vss "(@genres:{Music} @year:[1970 1979]) =>[KNN 5 @embedding $vec AS score]" ' +
70-
`PARAMS 2 vec ${String.raw`"\x9a\x99\x1d\x3e\xcd\xcc\x4c\xbd\x9a\x99\x99\x3e\x9a\x99\x19\x3e\x9a\x99\x19\xbe\x9a\x99\x1d\x3e\xcd\xcc\x0c\x3e\x9a\x99\xf1\xbc"`} ` +
71-
'SORTBY score ' +
72-
'RETURN 4 title year genres score ' +
73-
'DIALECT 2',
74-
},
75-
{
76-
label:
77-
'You like Animated and Sci-Fi movies. Personalize results by filtering the vector search',
78-
value:
79-
`FT.SEARCH idx:movies_vss '@genres:{"Animated"|"Sci-Fi"} =>[KNN 5 @embedding $vec AS score]' ` +
80-
`PARAMS 2 vec ${String.raw`"\x9a\x99\x1d\x3e\xcd\xcc\x4c\xbd\x9a\x99\x99\x3e\x9a\x99\x19\x3e\x9a\x99\x19\xbe\x9a\x99\x1d\x3e\xcd\xcc\x0c\x3e\x9a\x99\xf1\xbc"`} ` +
81-
'SORTBY score ' +
82-
'RETURN 3 title genres score ' +
83-
'DIALECT 2',
84-
},
85-
],
37+
queries: savedQueries[PresetDataType.MOVIES],
8638
},
8739
]
8840

0 commit comments

Comments
 (0)