-
Notifications
You must be signed in to change notification settings - Fork 3
Facet counts and aggregations for Vector search #3210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
878907c
d011419
8e9aa44
f36d1cb
ab34a23
22c8d43
518c5a1
73a080a
f3168d6
937ddf7
1c1ea40
11dfdc8
23d9bb4
7abd6f9
45a3011
ab4c0f8
d310643
ef6c227
3e1ed7a
d09c4b5
493fc35
c1b848f
de908ef
2668365
a17581b
15663a3
7d1c544
9a8f7db
803baf0
027114c
d654892
f58178d
13c0593
2348970
7fa59dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,50 +152,6 @@ describe("SearchPage", () => { | |
| }, | ||
| ) | ||
|
|
||
| test("Vector Hybrid Search passes correct params and hides count", async () => { | ||
| setMockApiResponses({ | ||
| search: { | ||
| count: 700, | ||
| metadata: { | ||
| aggregations: { | ||
| resource_type_group: [{ key: "course", doc_count: 100 }], | ||
| }, | ||
| suggestions: [], | ||
| }, | ||
| results: factories.learningResources.resources({ count: 5 }).results, | ||
| }, | ||
| }) | ||
|
|
||
| // Authenticate as path editor (admin) | ||
| setMockResponse.get(urls.userMe.get(), { | ||
| is_learning_path_editor: true, | ||
| is_authenticated: true, | ||
| }) | ||
|
|
||
| renderWithProviders(<SearchPage />, { url: "?vector_search=true&q=test" }) | ||
|
|
||
| await waitFor(() => { | ||
| const call = makeRequest.mock.calls.find(([_method, url]) => { | ||
| return url.includes(urls.search.vectorResources()) | ||
| }) | ||
| expect(call).toBeDefined() | ||
| }) | ||
|
|
||
| const call = makeRequest.mock.calls.find(([_method, url]) => | ||
| url.includes(urls.search.vectorResources()), | ||
| ) | ||
| invariant(call) | ||
| const fullUrl = new URL(call[1], "http://mit.edu") | ||
| const apiSearchParams = fullUrl.searchParams | ||
|
|
||
| expect(apiSearchParams.get("hybrid_search")).toBe("true") | ||
| expect(apiSearchParams.get("q")).toBe("test") | ||
|
|
||
| // Ensure count is hidden | ||
| const hideCountText = screen.queryByText("700 results") | ||
| expect(hideCountText).toBeNull() | ||
| }) | ||
|
|
||
| test("Toggling facets", async () => { | ||
| setMockApiResponses({ | ||
|
Comment on lines
155
to
156
|
||
| search: { | ||
|
|
@@ -1060,4 +1016,61 @@ describe("UniversalAIBanner", () => { | |
| expect(screen.queryByText("Universal AI")).not.toBeInTheDocument() | ||
| expect(screen.queryByText("New on MIT Learn")).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| test("Vector Hybrid Search passes correct params and renders expected count/facets", async () => { | ||
| setMockApiResponses({ | ||
| search: { | ||
| count: 700, | ||
| metadata: { | ||
| aggregations: { | ||
| resource_type_group: [{ key: "course", doc_count: 100 }], | ||
| }, | ||
| suggestions: [], | ||
| }, | ||
| results: factories.learningResources.resources({ count: 5 }).results, | ||
| }, | ||
| }) | ||
|
|
||
| // Authenticate as path editor (admin) | ||
| setMockResponse.get(urls.userMe.get(), { | ||
| is_learning_path_editor: true, | ||
| is_authenticated: true, | ||
| }) | ||
|
|
||
| renderWithProviders(<SearchPage />, { url: "?vector_search=true&q=test" }) | ||
|
|
||
| await waitFor(() => { | ||
| const call = makeRequest.mock.calls.find(([_method, url]) => { | ||
| return url.includes(urls.search.vectorResources()) | ||
| }) | ||
| expect(call).toBeDefined() | ||
| }) | ||
|
|
||
| const call = makeRequest.mock.calls.find(([_method, url]) => | ||
| url.includes(urls.search.vectorResources()), | ||
| ) | ||
| invariant(call) | ||
| const fullUrl = new URL(call[1], "http://mit.edu") | ||
| const apiSearchParams = fullUrl.searchParams | ||
|
|
||
| expect(apiSearchParams.get("hybrid_search")).toBe("true") | ||
| expect(apiSearchParams.get("q")).toBe("test") | ||
|
|
||
| // Ensure count is visible | ||
| const countText = await screen.findByText("700 results") | ||
| expect(countText).toBeVisible() | ||
|
|
||
| // Ensure facets are visible | ||
| await waitFor(() => { | ||
| const tabs = screen.getAllByRole("tab") | ||
| expect( | ||
| tabs.map((tab) => (tab.textContent || "").replace(/\s/g, "")), | ||
| ).toEqual([ | ||
| "All(100)", | ||
| "Courses(100)", | ||
| "Programs(0)", | ||
| "LearningMaterials(0)", | ||
| ]) | ||
| }) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -822,10 +822,10 @@ def get_all_config_keys(): | |
| QDRANT_CLIENT_TIMEOUT = get_int(name="QDRANT_CLIENT_TIMEOUT", default=10) | ||
|
|
||
| VECTOR_HYBRID_SEARCH_PREFETCH_MULTIPLIER = get_int( | ||
| name="VECTOR_HYBRID_SEARCH_PREFETCH_MULTIPLIER", default=20 | ||
| name="VECTOR_HYBRID_SEARCH_PREFETCH_MULTIPLIER", default=5 | ||
| ) | ||
| VECTOR_HYBRID_SEARCH_PREFETCH_MAX_LIMIT = get_int( | ||
| name="VECTOR_HYBRID_SEARCH_PREFETCH_MAX_LIMIT", default=10000 | ||
| name="VECTOR_HYBRID_SEARCH_PREFETCH_MAX_LIMIT", default=500 | ||
| ) | ||
|
Comment on lines
824
to
829
|
||
| # toggle to use requests (default for local) or webdriver which renders js elements | ||
| EMBEDDINGS_EXTERNAL_FETCH_USE_WEBDRIVER = get_bool( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the copilot review, probably better to update this test rather than remove it altogether, if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restored and updated