Skip to content

Commit 54e6161

Browse files
author
Richard Kuo (Onyx)
committed
prototype for surfacing docs without a query
1 parent f08fa87 commit 54e6161

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Diff for: backend/onyx/document_index/vespa/index.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -821,26 +821,30 @@ def admin_retrieval(
821821
num_to_retrieve: int = NUM_RETURNED_HITS,
822822
offset: int = 0,
823823
) -> list[InferenceChunkUncleaned]:
824-
vespa_where_clauses = build_vespa_filters(filters, include_hidden=True)
825-
yql = (
826-
YQL_BASE.format(index_name=self.index_name)
827-
+ vespa_where_clauses
828-
+ '({grammar: "weakAnd"}userInput(@query) '
829-
# `({defaultIndex: "content_summary"}userInput(@query))` section is
830-
# needed for highlighting while the N-gram highlighting is broken /
831-
# not working as desired
832-
+ f'or ({{defaultIndex: "{CONTENT_SUMMARY}"}}userInput(@query)))'
824+
vespa_where_clauses = build_vespa_filters(
825+
filters, include_hidden=True, remove_trailing_and=True
833826
)
827+
yql = YQL_BASE.format(index_name=self.index_name) + vespa_where_clauses
834828

835829
params: dict[str, str | int] = {
836830
"yql": yql,
837-
"query": query,
838831
"hits": num_to_retrieve,
839832
"offset": 0,
840833
"ranking.profile": "admin_search",
841834
"timeout": VESPA_TIMEOUT,
842835
}
843836

837+
if len(query.strip()) > 0:
838+
yql += (
839+
' and ({grammar: "weakAnd"}userInput(@query) '
840+
# `({defaultIndex: "content_summary"}userInput(@query))` section is
841+
# needed for highlighting while the N-gram highlighting is broken /
842+
# not working as desired
843+
+ f'or ({{defaultIndex: "{CONTENT_SUMMARY}"}}userInput(@query)))'
844+
)
845+
params["yql"] = yql
846+
params["query"] = query
847+
844848
return query_vespa(params)
845849

846850
# Retrieves chunk information for a document:

Diff for: web/src/app/admin/documents/explorer/Explorer.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ export function Explorer({
148148
clearTimeout(timeoutId);
149149
}
150150

151-
if (query && query.trim() !== "") {
151+
let doSearch = true;
152+
if (doSearch) {
152153
router.replace(
153154
`/admin/documents/explorer?query=${encodeURIComponent(query)}`
154155
);

Diff for: web/src/components/user/UserProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function UserProvider({
102102
};
103103

104104
// Use the custom token refresh hook
105-
useTokenRefresh(upToDateUser, fetchUser);
105+
// useTokenRefresh(upToDateUser, fetchUser);
106106

107107
const updateUserTemperatureOverrideEnabled = async (enabled: boolean) => {
108108
try {

0 commit comments

Comments
 (0)