Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion frontends/search/src/components/ResultsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const ResultsPage = (props: ResultsPageProps) => {
rating: 5,
note: "",
});
const [correctedQuery, setCorrectedQuery] = createSignal("");

const [serverTimings, setServerTimings] = createSignal<ServerTiming[]>([]);
const [showServerTimings, setShowServerTimings] = createSignal(false);
Expand Down Expand Up @@ -364,6 +365,7 @@ const ResultsPage = (props: ResultsPageProps) => {
const groupResult = data.results as GroupScoreChunkDTO[];
setTotalPages(data.total_pages);
setSearchID(data.id);
setCorrectedQuery(data.corrected_query);
setGroupResultChunks(groupResult);

resultingChunks = groupResult.flatMap((groupChunkDTO) => {
Expand All @@ -383,6 +385,7 @@ const ResultsPage = (props: ResultsPageProps) => {
});
setSearchID(data.id);
setResultChunks(resultingChunks);
setCorrectedQuery(data.corrected_query);
setTotalPages(data.total_pages);
}

Expand Down Expand Up @@ -454,7 +457,7 @@ const ResultsPage = (props: ResultsPageProps) => {
</FullScreenModal>
</Portal>
</Show>
<div class="flex w-full flex-col items-center gap-4 pt-12">
<div class="flex w-full flex-col items-center gap-4 pt-5">
<Switch>
<Match when={loading()}>
<div
Expand All @@ -473,6 +476,54 @@ const ResultsPage = (props: ResultsPageProps) => {
</div>
</Match>
<Match when={!loading() && groupResultChunks().length == 0}>
<Show when={correctedQuery()}>
<div class="flex w-full flex-col">
<div class="text-lg">
{" "}
Showing results for{" "}
<a
class="font-bold text-blue-500"
href={`${new URL(window.location.href).origin}${
new URL(window.location.href).pathname
}?${new URLSearchParams({
...Object.fromEntries(
new URL(window.location.href).searchParams,
),
query: correctedQuery(),
}).toString()}`}
onClick={() => {
props.search.setSearch({
query: correctedQuery(),
});
}}
>
{correctedQuery()}
</a>
</div>
<div>
Search instead for
<a
class="pl-1 font-bold text-blue-500"
href={`${new URL(window.location.href).origin}${
new URL(window.location.href).pathname
}?${new URLSearchParams({
...Object.fromEntries(
new URL(window.location.href).searchParams,
),
query: `"${props.search.debounced.query}"`,
}).toString()}`}
onClick={() => {
props.search.setSearch({
query: `"${props.search.debounced.query}"`,
});
}}
>
{props.search.debounced.query}
</a>
</div>
</div>
</Show>

<ShowServerTimings />
<div class="flex w-full max-w-screen-2xl flex-col space-y-4">
<For each={resultChunks()}>
Expand Down
1 change: 1 addition & 0 deletions frontends/search/src/utils/apiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface ChunkBookmarksDTO {

export interface ChunksWithTotalPagesDTO {
chunks: ScoreChunkDTO[];
corrected_query?: string;
total_pages: number;
}

Expand Down