Skip to content

Commit 140f19f

Browse files
committed
fix: update flexsearch to support accent insensitive search
1 parent de5fb80 commit 140f19f

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

helm-charts/catalogi/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: catalogi
33
description: A Helm chart for deploying the Catalogi open source software catalog.
44
type: application
5-
version: 2.0.20
6-
appVersion: 1.53.3
5+
version: 2.0.21
6+
appVersion: 1.53.4
77
dependencies:
88
- name: postgresql
99
version: '16'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sill",
3-
"version": "1.53.3",
3+
"version": "1.53.4",
44
"license": "MIT",
55
"private": true,
66
"scripts": {

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@uiw/react-md-editor": "^3.23.5",
3131
"api": "*",
3232
"evt": "^2.5.7",
33-
"flexsearch": "0.7.43",
33+
"flexsearch": "^0.8.212",
3434
"i18next": "^23.6.0",
3535
"i18next-browser-languagedetector": "^8.0.2",
3636
"i18next-http-backend": "^3.0.2",

web/src/core/usecases/softwareCatalog/thunks.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,32 +312,31 @@ function apiSoftwareToInternalSoftware(params: {
312312
const { filterBySearchMemoized } = (() => {
313313
const getFlexSearch = memoize(
314314
(softwares: State.Software.Internal[]) => {
315-
const index = new FlexSearch.Document<State.Software.Internal>({
315+
const index = new FlexSearch.Document({
316316
document: {
317317
id: "softwareName",
318318
field: ["search"]
319319
},
320320
cache: 100,
321321
tokenize: "full",
322-
charset: {
323-
split: /\s+/,
324-
rtl: false,
325-
encode: (str: string): string[] => {
326-
const normalized = str
327-
.normalize("NFD")
328-
.replace(/[\u0300-\u036f]/g, "")
329-
.toLowerCase();
330-
return [normalized];
331-
}
332-
},
322+
encoder: "Default",
333323
context: {
334324
resolution: 9,
335325
depth: 2,
336326
bidirectional: true
337327
}
338328
});
339329

340-
softwares.forEach(software => index.add(software));
330+
softwares.forEach(
331+
({
332+
logoUrl,
333+
latestVersion,
334+
userDeclaration,
335+
referencePublications,
336+
customAttributes,
337+
...software
338+
}) => index.add(software)
339+
);
341340

342341
return index;
343342
},
@@ -376,7 +375,6 @@ const { filterBySearchMemoized } = (() => {
376375
const index = getFlexSearch(softwares);
377376

378377
const searchResult = await index.searchAsync(search, {
379-
bool: "or",
380378
suggest: true,
381379
enrich: true
382380
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,10 +4189,10 @@ flatted@^3.2.9:
41894189
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.3.tgz#67c8fad95454a7c7abebf74bb78ee74a44023358"
41904190
integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==
41914191

4192-
flexsearch@0.7.43:
4193-
version "0.7.43"
4194-
resolved "https://registry.yarnpkg.com/flexsearch/-/flexsearch-0.7.43.tgz#34f89b36278a466ce379c5bf6fb341965ed3f16c"
4195-
integrity sha512-c5o/+Um8aqCSOXGcZoqZOm+NqtVwNsvVpWv6lfmSclU954O3wvQKxxK8zj74fPaSJbXpSLTs4PRhh+wnoCXnKg==
4192+
flexsearch@^0.8.212:
4193+
version "0.8.212"
4194+
resolved "https://registry.yarnpkg.com/flexsearch/-/flexsearch-0.8.212.tgz#b9509af778a991b938292e36fe0809a4ece4b940"
4195+
integrity sha512-wSyJr1GUWoOOIISRu+X2IXiOcVfg9qqBRyCPRUdLMIGJqPzMo+jMRlvE83t14v1j0dRMEaBbER/adQjp6Du2pw==
41964196

41974197
for-each@^0.3.3:
41984198
version "0.3.5"

0 commit comments

Comments
 (0)