Skip to content

Commit

Permalink
feature: add flag to search UI
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryanpunia authored and skeptrunedev committed Jul 29, 2024
1 parent 16ad558 commit dae21b9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontends/search/src/components/GroupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export const GroupPage = (props: GroupPageProps) => {
highlight_window: search.debounced.highlightWindow,
sort_by: sort_by,
use_quote_negated_terms: search.debounced.useQuoteNegatedTerms,
remove_stop_words: search.debounced.removeStopWords,
}),
}).then((response) => {
if (response.ok) {
Expand Down
1 change: 1 addition & 0 deletions frontends/search/src/components/ResultsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const ResultsPage = (props: ResultsPageProps) => {
highlight_window: props.search.debounced.highlightWindow ?? 0,
group_size: props.search.debounced.group_size ?? 3,
use_quote_negated_terms: props.search.debounced.useQuoteNegatedTerms,
remove_stop_words: props.search.debounced.removeStopWords,
};

let searchRoute = "";
Expand Down
17 changes: 17 additions & 0 deletions frontends/search/src/components/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ const SearchForm = (props: { search: SearchStore; groupID?: string }) => {
highlightMaxNum: 3,
highlightWindow: 0,
group_size: 3,
removeStopWords: false,
} as SearchOptions;
});
}}
Expand Down Expand Up @@ -994,6 +995,22 @@ const SearchForm = (props: { search: SearchStore; groupID?: string }) => {
}}
/>
</div>
<div class="flex items-center justify-between space-x-2 p-1">
<label>Remove Stop Words</label>
<input
class="h-4 w-4"
type="checkbox"
checked={tempSearchValues().removeStopWords}
onChange={(e) => {
setTempSearchValues((prev) => {
return {
...prev,
removeStopWords: e.target.checked,
};
});
}}
/>
</div>
<div class="flex items-center justify-between space-x-2 p-1">
<label>Highlight Results (Latency Penalty):</label>
<input
Expand Down
4 changes: 4 additions & 0 deletions frontends/search/src/hooks/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface SearchOptions {
highlightWindow: number;
group_size: number;
useQuoteNegatedTerms: boolean;
removeStopWords: boolean;
}

const initalState: SearchOptions = {
Expand All @@ -75,6 +76,7 @@ const initalState: SearchOptions = {
highlightWindow: 0,
group_size: 3,
useQuoteNegatedTerms: false,
removeStopWords: false,
};

const fromStateToParams = (state: SearchOptions): Params => {
Expand All @@ -98,6 +100,7 @@ const fromStateToParams = (state: SearchOptions): Params => {
highlightWindow: state.highlightWindow.toString(),
group_size: state.group_size?.toString(),
useQuoteNegatedTerms: state.useQuoteNegatedTerms.toString(),
removeStopWords: state.removeStopWords.toString(),
};
};

Expand Down Expand Up @@ -128,6 +131,7 @@ const fromParamsToState = (
highlightWindow: parseInt(params.highlightWindow ?? "0"),
group_size: parseInt(params.group_size ?? "3"),
useQuoteNegatedTerms: (params.useQuoteNegatedTerms ?? "false") === "true",
removeStopWords: (params.removeStopWords ?? "false") === "true",
};
};

Expand Down

0 comments on commit dae21b9

Please sign in to comment.