Fixed logDebug() call

This commit is contained in:
Simon Cambier
2024-01-22 22:12:41 +01:00
parent cf1c328e77
commit 4b8bf437ce
2 changed files with 6 additions and 6 deletions

View File

@@ -172,7 +172,9 @@ export class Omnisearch {
break
}
let results = this.minisearch.search(tokenizeForSearch(query.segmentsToStr()), {
const searchTokens = tokenizeForSearch(query.segmentsToStr())
logDebug(JSON.stringify(searchTokens, null, 1))
let results = this.minisearch.search(searchTokens, {
prefix: term => term.length >= options.prefixLength,
// length <= 3: no fuzziness
// length <= 5: fuzziness of 10%

View File

@@ -58,24 +58,22 @@ export function tokenizeForIndexing(text: string): string[] {
export function tokenizeForSearch(text: string): QueryCombination {
const tokens = tokenizeTokens(text)
const chsSegmenter = getChsSegmenter()
let chs: string[] = []
const chsSegmenter = getChsSegmenter()
if (chsSegmenter) {
chs = tokens.flatMap(word =>
chsRegex.test(word) ? chsSegmenter.cut(word) : [word]
)
}
const query = {
return {
combineWith: 'OR',
queries: [
{ combineWith: 'AND', queries: tokens },
{ combineWith: 'AND', queries: tokenizeWords(text) },
{ combineWith: 'AND', queries: tokens.flatMap(splitHyphens) },
{ combineWith: 'AND', queries: tokens.flatMap(splitCamelCase) },
{ combineWith: 'AND', queries: chs },
{ combineWith: 'AND', queries: tokenizeWords(text) },
],
}
logDebug(JSON.stringify(query, null, 1))
return query
}