cry-search 1.0.8 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/numeric/findInLinkedArrays.d.ts.map +1 -1
- package/dist/index.cjs +43 -12
- package/dist/index.js +43 -12
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findInLinkedArrays.d.ts","sourceRoot":"","sources":["../../../src/common/numeric/findInLinkedArrays.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AAUxF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAEhC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC9D,KAAK,GAAE,MAAW,EAClB,IAAI,CAAC,EAAE,UAAU,GAChB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"findInLinkedArrays.d.ts","sourceRoot":"","sources":["../../../src/common/numeric/findInLinkedArrays.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AAUxF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAEhC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC9D,KAAK,GAAE,MAAW,EAClB,IAAI,CAAC,EAAE,UAAU,GAChB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAmO/C;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAEhC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC9D,KAAK,GAAE,MAAW,EAClB,IAAI,CAAC,EAAE,UAAU,GAChB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAEzC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1019,6 +1019,30 @@ function findInLinkedArraysNumeric(query, linked, limit = 10, opts) {
|
|
|
1019
1019
|
}
|
|
1020
1020
|
if (negatedMatchesInPrimary)
|
|
1021
1021
|
continue;
|
|
1022
|
+
let allPositiveMatchInPrimary = true;
|
|
1023
|
+
for (const token of positiveTokens) {
|
|
1024
|
+
if (!matchPreparedTokenInSortedList(token, primaryTokens, opts)) {
|
|
1025
|
+
allPositiveMatchInPrimary = false;
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
if (allPositiveMatchInPrimary && negatedTokens.length === 0) {
|
|
1030
|
+
const matchedLinked2 = linkedIds.map((id) => linked.linkedData.get(id)).filter((item) => item !== undefined);
|
|
1031
|
+
scored.push({
|
|
1032
|
+
result: {
|
|
1033
|
+
primary,
|
|
1034
|
+
linked: matchedLinked2,
|
|
1035
|
+
matchedIn: "primary"
|
|
1036
|
+
},
|
|
1037
|
+
score: 0,
|
|
1038
|
+
order: orderCounter++,
|
|
1039
|
+
primaryId,
|
|
1040
|
+
matchedLinkedIds: matchedLinked2.map((l) => l._id)
|
|
1041
|
+
});
|
|
1042
|
+
continue;
|
|
1043
|
+
}
|
|
1044
|
+
if (!allPositiveMatchInPrimary && linkedIds.length === 0)
|
|
1045
|
+
continue;
|
|
1022
1046
|
let totalLength = primaryTokens.length;
|
|
1023
1047
|
for (const linkedId of linkedIds) {
|
|
1024
1048
|
const linkedTokens = linked.linkedMeta.sorted.get(linkedId);
|
|
@@ -1037,24 +1061,31 @@ function findInLinkedArraysNumeric(query, linked, limit = 10, opts) {
|
|
|
1037
1061
|
}
|
|
1038
1062
|
}
|
|
1039
1063
|
allTokens.sort();
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1064
|
+
if (!allPositiveMatchInPrimary) {
|
|
1065
|
+
let allPositiveMatch = true;
|
|
1066
|
+
for (const token of positiveTokens) {
|
|
1067
|
+
if (!matchPreparedTokenInSortedList(token, allTokens, opts)) {
|
|
1068
|
+
allPositiveMatch = false;
|
|
1069
|
+
break;
|
|
1070
|
+
}
|
|
1045
1071
|
}
|
|
1072
|
+
if (!allPositiveMatch)
|
|
1073
|
+
continue;
|
|
1046
1074
|
}
|
|
1047
|
-
|
|
1048
|
-
continue;
|
|
1049
|
-
let anyMatchInPrimary = false;
|
|
1075
|
+
let anyMatchInPrimary = allPositiveMatchInPrimary;
|
|
1050
1076
|
let anyMatchInLinked = false;
|
|
1051
1077
|
const matchingLinkedIds = new Set;
|
|
1052
1078
|
const tokensMatchingPrimary = new Set;
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1079
|
+
if (!allPositiveMatchInPrimary) {
|
|
1080
|
+
for (const preparedToken of positiveTokens) {
|
|
1081
|
+
if (matchPreparedTokenInSortedList(preparedToken, primaryTokens, opts)) {
|
|
1082
|
+
anyMatchInPrimary = true;
|
|
1083
|
+
tokensMatchingPrimary.add(preparedToken);
|
|
1084
|
+
}
|
|
1057
1085
|
}
|
|
1086
|
+
} else {
|
|
1087
|
+
for (const t of positiveTokens)
|
|
1088
|
+
tokensMatchingPrimary.add(t);
|
|
1058
1089
|
}
|
|
1059
1090
|
const tokensForLinkedMatching = positiveTokens.filter((t) => !tokensMatchingPrimary.has(t));
|
|
1060
1091
|
if (tokensForLinkedMatching.length > 0 || negatedTokens.length > 0) {
|
package/dist/index.js
CHANGED
|
@@ -926,6 +926,30 @@ function findInLinkedArraysNumeric(query, linked, limit = 10, opts) {
|
|
|
926
926
|
}
|
|
927
927
|
if (negatedMatchesInPrimary)
|
|
928
928
|
continue;
|
|
929
|
+
let allPositiveMatchInPrimary = true;
|
|
930
|
+
for (const token of positiveTokens) {
|
|
931
|
+
if (!matchPreparedTokenInSortedList(token, primaryTokens, opts)) {
|
|
932
|
+
allPositiveMatchInPrimary = false;
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
if (allPositiveMatchInPrimary && negatedTokens.length === 0) {
|
|
937
|
+
const matchedLinked2 = linkedIds.map((id) => linked.linkedData.get(id)).filter((item) => item !== undefined);
|
|
938
|
+
scored.push({
|
|
939
|
+
result: {
|
|
940
|
+
primary,
|
|
941
|
+
linked: matchedLinked2,
|
|
942
|
+
matchedIn: "primary"
|
|
943
|
+
},
|
|
944
|
+
score: 0,
|
|
945
|
+
order: orderCounter++,
|
|
946
|
+
primaryId,
|
|
947
|
+
matchedLinkedIds: matchedLinked2.map((l) => l._id)
|
|
948
|
+
});
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
if (!allPositiveMatchInPrimary && linkedIds.length === 0)
|
|
952
|
+
continue;
|
|
929
953
|
let totalLength = primaryTokens.length;
|
|
930
954
|
for (const linkedId of linkedIds) {
|
|
931
955
|
const linkedTokens = linked.linkedMeta.sorted.get(linkedId);
|
|
@@ -944,24 +968,31 @@ function findInLinkedArraysNumeric(query, linked, limit = 10, opts) {
|
|
|
944
968
|
}
|
|
945
969
|
}
|
|
946
970
|
allTokens.sort();
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
971
|
+
if (!allPositiveMatchInPrimary) {
|
|
972
|
+
let allPositiveMatch = true;
|
|
973
|
+
for (const token of positiveTokens) {
|
|
974
|
+
if (!matchPreparedTokenInSortedList(token, allTokens, opts)) {
|
|
975
|
+
allPositiveMatch = false;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
952
978
|
}
|
|
979
|
+
if (!allPositiveMatch)
|
|
980
|
+
continue;
|
|
953
981
|
}
|
|
954
|
-
|
|
955
|
-
continue;
|
|
956
|
-
let anyMatchInPrimary = false;
|
|
982
|
+
let anyMatchInPrimary = allPositiveMatchInPrimary;
|
|
957
983
|
let anyMatchInLinked = false;
|
|
958
984
|
const matchingLinkedIds = new Set;
|
|
959
985
|
const tokensMatchingPrimary = new Set;
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
986
|
+
if (!allPositiveMatchInPrimary) {
|
|
987
|
+
for (const preparedToken of positiveTokens) {
|
|
988
|
+
if (matchPreparedTokenInSortedList(preparedToken, primaryTokens, opts)) {
|
|
989
|
+
anyMatchInPrimary = true;
|
|
990
|
+
tokensMatchingPrimary.add(preparedToken);
|
|
991
|
+
}
|
|
964
992
|
}
|
|
993
|
+
} else {
|
|
994
|
+
for (const t of positiveTokens)
|
|
995
|
+
tokensMatchingPrimary.add(t);
|
|
965
996
|
}
|
|
966
997
|
const tokensForLinkedMatching = positiveTokens.filter((t) => !tokensMatchingPrimary.has(t));
|
|
967
998
|
if (tokensForLinkedMatching.length > 0 || negatedTokens.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cry-search",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A fast, memory-efficient search library for large datasets with support for tokenized matching, linked collections, and per-field match modes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|