Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/database/search-utils.js
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
const fulltextOperands = ['+', '<', '>', '~']; | const fulltextOperands = ['+', '<', '>', '~']; | ||||
function processQueryForSearch(query: string): string { | function processQueryForSearch(query: string): string { | ||||
if (query === '') { | if (query === '') { | ||||
return ''; | return ''; | ||||
} | } | ||||
const stemmedQuery = segmentAndStem(query); | const stemmedQuery = segmentAndStem(query); | ||||
if (stemmedQuery === '') { | |||||
return ''; | |||||
} | |||||
return stemmedQuery | return stemmedQuery | ||||
.split(' ') | .split(' ') | ||||
.filter(word => !fulltextOperands.includes(word)) | .filter(word => !fulltextOperands.includes(word)) | ||||
.map(segment => `+${segment}`) | .map(segment => `+${segment}`) | ||||
.join(' '); | .join(' '); | ||||
} | } | ||||
export { | export { | ||||
processMessagesForSearch, | processMessagesForSearch, | ||||
processMessagesInDBForSearch, | processMessagesInDBForSearch, | ||||
segmentAndStem, | segmentAndStem, | ||||
stopwords, | stopwords, | ||||
processQueryForSearch, | processQueryForSearch, | ||||
}; | }; |