Skip to content

Commit

Permalink
Merge pull request #69 from aws-solutions-library-samples/bugfixes/se…
Browse files Browse the repository at this point in the history
…arch-timeout-issue

remove tokenizer as it causes timeout on http request.
  • Loading branch information
aws-kens authored Feb 7, 2025
2 parents 46ff740 + aaa032a commit e4f9cc0
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions source/api/lib/operations/searchOp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

const Tokenizer = require('wink-tokenizer')();
const {
Indexer,
CommonUtils,
Expand Down Expand Up @@ -36,29 +35,18 @@ function multimatch(a, b) {
let matches = a.localeCompare(b, undefined, {
sensitivity: 'base',
});

if (matches === 0) {
return true;
}

const tokenA = Tokenizer.tokenize(a)
.map((token) =>
token.value);
const tokenB = Tokenizer.tokenize(b)
.map((token) =>
token.value);

matches = 0;
tokenB.forEach((token) => {
const match = tokenA.find((x) =>
x.localeCompare(token, undefined, {
sensitivity: 'base',
}) === 0);
if (match !== undefined) {
matches += 1;
}
});
if (matches < 0) {
matches = b.localeCompare(a, undefined, {
sensitivity: 'base',
});
}

if (matches === tokenB.length) {
if (matches === 0) {
return true;
}

Expand Down

0 comments on commit e4f9cc0

Please sign in to comment.