mirror of
https://github.com/simon987/sist2.git
synced 2025-04-18 17:56:44 +00:00
fuzzy toggle
This commit is contained in:
parent
152d2ddf8a
commit
2d7a8a2fdc
File diff suppressed because one or more lines are too long
@ -36,6 +36,10 @@ function toggleSearchBar() {
|
||||
searchDebounced();
|
||||
}
|
||||
|
||||
function toggleFuzzy() {
|
||||
searchDebounced();
|
||||
}
|
||||
|
||||
$.jsonPost("i").then(resp => {
|
||||
resp["indices"].forEach(idx => {
|
||||
const opt = $("<option>")
|
||||
@ -223,6 +227,17 @@ function search() {
|
||||
{range: {size: {gte: size_min, lte: size_max}}},
|
||||
{terms: {index: selectedIndices}}
|
||||
];
|
||||
let fields = [
|
||||
"name^8",
|
||||
"content^3",
|
||||
"album^8", "artist^8", "title^8", "genre^2", "album_artist^8",
|
||||
"font_name^6"
|
||||
];
|
||||
|
||||
if ($("#fuzzyToggle").prop("checked")) {
|
||||
fields.push("content.nGram");
|
||||
fields.push("name.nGram^3");
|
||||
}
|
||||
|
||||
let path = pathBar.value.replace(/\/$/, "").toLowerCase(); //remove trailing slashes
|
||||
if (path !== "") {
|
||||
@ -243,12 +258,7 @@ function search() {
|
||||
multi_match: {
|
||||
query: query,
|
||||
type: "most_fields",
|
||||
fields: [
|
||||
"name^8", "name.nGram^3", "content^3",
|
||||
"content.nGram",
|
||||
"album^8", "artist^8", "title^8", "genre^2", "album_artist^8",
|
||||
"font_name^6"
|
||||
],
|
||||
fields: fields,
|
||||
operator: "and"
|
||||
}
|
||||
},
|
||||
|
@ -27,6 +27,9 @@
|
||||
<span onclick="document.getElementById('barToggle').click()">Must match </span>
|
||||
<input title="Toggle between 'Should' and 'Must' match mode" type="checkbox" id="barToggle"
|
||||
onclick="toggleSearchBar()" checked>
|
||||
<span onclick="document.getElementById('fuzzyToggle').click()">  Fuzzy </span>
|
||||
<input title="Toggle fuzzy searching" type="checkbox" id="fuzzyToggle"
|
||||
onclick="toggleFuzzy()" checked>
|
||||
</div>
|
||||
</div>
|
||||
<input id="searchBar" type="search" class="form-control" placeholder="Search">
|
||||
|
Loading…
x
Reference in New Issue
Block a user