Fixed logDebug() call
This commit is contained in:
@@ -172,7 +172,9 @@ export class Omnisearch {
|
|||||||
break
|
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,
|
prefix: term => term.length >= options.prefixLength,
|
||||||
// length <= 3: no fuzziness
|
// length <= 3: no fuzziness
|
||||||
// length <= 5: fuzziness of 10%
|
// length <= 5: fuzziness of 10%
|
||||||
|
|||||||
@@ -58,24 +58,22 @@ export function tokenizeForIndexing(text: string): string[] {
|
|||||||
export function tokenizeForSearch(text: string): QueryCombination {
|
export function tokenizeForSearch(text: string): QueryCombination {
|
||||||
const tokens = tokenizeTokens(text)
|
const tokens = tokenizeTokens(text)
|
||||||
|
|
||||||
const chsSegmenter = getChsSegmenter()
|
|
||||||
let chs: string[] = []
|
let chs: string[] = []
|
||||||
|
const chsSegmenter = getChsSegmenter()
|
||||||
if (chsSegmenter) {
|
if (chsSegmenter) {
|
||||||
chs = tokens.flatMap(word =>
|
chs = tokens.flatMap(word =>
|
||||||
chsRegex.test(word) ? chsSegmenter.cut(word) : [word]
|
chsRegex.test(word) ? chsSegmenter.cut(word) : [word]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = {
|
return {
|
||||||
combineWith: 'OR',
|
combineWith: 'OR',
|
||||||
queries: [
|
queries: [
|
||||||
{ combineWith: 'AND', queries: tokens },
|
{ combineWith: 'AND', queries: tokens },
|
||||||
|
{ combineWith: 'AND', queries: tokenizeWords(text) },
|
||||||
{ combineWith: 'AND', queries: tokens.flatMap(splitHyphens) },
|
{ combineWith: 'AND', queries: tokens.flatMap(splitHyphens) },
|
||||||
{ combineWith: 'AND', queries: tokens.flatMap(splitCamelCase) },
|
{ combineWith: 'AND', queries: tokens.flatMap(splitCamelCase) },
|
||||||
{ combineWith: 'AND', queries: chs },
|
{ combineWith: 'AND', queries: chs },
|
||||||
{ combineWith: 'AND', queries: tokenizeWords(text) },
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
logDebug(JSON.stringify(query, null, 1))
|
|
||||||
return query
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user