Skip to content
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

feature: recognize domain specific words #2273

Merged
merged 6 commits into from
Sep 3, 2024
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
2 changes: 2 additions & 0 deletions frontends/search/src/components/ResultsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ const ResultsPage = (props: ResultsPageProps) => {
max: props.search.debounced.twoTypoWordRangeMax,
},
disable_on_word: props.search.debounced.disableOnWords,
prioritize_domain_specifc_words:
props.search.debounced.prioritize_domain_specifc_words,
},
highlight_options: {
highlight_results: props.search.debounced.highlightResults ?? true,
Expand Down
21 changes: 21 additions & 0 deletions frontends/search/src/components/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ const SearchForm = (props: {
twoTypoWordRangeMax: null,
disableOnWords: [],
typoTolerance: false,
prioritize_domain_specifc_words: true,
highlightResults: true,
highlightDelimiters: ["?", ".", "!"],
highlightMaxLength: 8,
Expand Down Expand Up @@ -1219,6 +1220,26 @@ const SearchForm = (props: {
}}
/>
</div>
<div class="flex items-center justify-between space-x-2 p-1">
<label>Auto-require Domain Keywords</label>
<input
class="h-4 w-4"
type="checkbox"
checked={
tempSearchValues()
.prioritize_domain_specifc_words ?? false
}
onChange={(e) => {
setTempSearchValues((prev) => {
return {
...prev,
prioritize_domain_specifc_words:
e.target.checked,
};
});
}}
/>
</div>
<div class="items flex justify-between space-x-2 p-1">
<label>One typo min word length:</label>
<input
Expand Down
6 changes: 6 additions & 0 deletions frontends/search/src/hooks/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface SearchOptions {
oneTypoWordRangeMax: number | null;
twoTypoWordRangeMin: number;
twoTypoWordRangeMax: number | null;
prioritize_domain_specifc_words: boolean | null;
disableOnWords: string[];
sort_by: SortByField | SortBySearchType;
pageSize: number;
Expand Down Expand Up @@ -102,6 +103,7 @@ const initalState: SearchOptions = {
oneTypoWordRangeMax: 8,
twoTypoWordRangeMin: 8,
twoTypoWordRangeMax: null,
prioritize_domain_specifc_words: true,
disableOnWords: [],
highlightResults: true,
highlightStrategy: "exactmatch",
Expand Down Expand Up @@ -140,6 +142,8 @@ const fromStateToParams = (state: SearchOptions): Params => {
oneTypoWordRangeMax: state.oneTypoWordRangeMax?.toString() ?? "8",
twoTypoWordRangeMin: state.twoTypoWordRangeMin.toString(),
twoTypoWordRangeMax: state.twoTypoWordRangeMax?.toString() ?? "",
prioritize_domain_specifc_words:
state.prioritize_domain_specifc_words?.toString() ?? "",
disableOnWords: state.disableOnWords.join(","),
highlightStrategy: state.highlightStrategy,
highlightResults: state.highlightResults.toString(),
Expand Down Expand Up @@ -184,6 +188,8 @@ const fromParamsToState = (
oneTypoWordRangeMax: parseIntOrNull(params.oneTypoWordRangeMax),
twoTypoWordRangeMin: parseInt(params.oneTypoWordRangeMin ?? "8"),
twoTypoWordRangeMax: parseIntOrNull(params.twoTypoWordRangeMax),
prioritize_domain_specifc_words:
(params.prioritize_domain_specifc_words ?? "true") === "true",
disableOnWords: params.disableOnWords?.split(",") ?? [],
highlightResults: (params.highlightResults ?? "true") === "true",
highlightStrategy: isHighlightStrategy(params.highlightStrategy)
Expand Down
73 changes: 2 additions & 71 deletions server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,10 @@ murmur3 = "0.5.2"
tantivy = "0.22.0"
strsim = "0.11.1"
levenshtein_automata = "0.2.1"
bktree = "1.0.1"
flate2 = "1.0.31"
bincode = "1.3"
rayon = "1.10.0"
crossbeam = "0.8.4"
bloomfilter = "1.0.14"
dashmap = "6.0.1"


Expand Down
2 changes: 2 additions & 0 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5296,6 +5296,8 @@ pub struct TypoOptions {
pub two_typo_word_range: Option<TypoRange>,
/// Words that should not be corrected. If not specified, this defaults to an empty list.
pub disable_on_word: Option<Vec<String>>,
/// Auto-require non-english words present in the dataset to exist in each results chunk_html text. If not specified, this defaults to true.
pub prioritize_domain_specifc_words: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, Default)]
Expand Down
Loading
Loading