Skip to content

Commit 97f8cac

Browse files
try fuzzy query instead of wildcard
1 parent 2c7d92d commit 97f8cac

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/services/ChallengeService.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,23 @@ async function searchChallenges (currentUser, criteria) {
196196
}
197197

198198
if (criteria.name) {
199-
boolQuery.push({ wildcard: { name: `*${_.toLower(criteria.name)}*` } })
199+
boolQuery.push({
200+
multi_match: {
201+
query: _.toLower(criteria.name),
202+
fields: ['name'],
203+
fuzziness: 'AUTO'
204+
}
205+
})
200206
}
201207
if (criteria.description) {
202-
boolQuery.push({ wildcard: { description: `*${_.toLower(criteria.description)}*` } })
208+
boolQuery.push({
209+
multi_match: {
210+
query: _.toLower(criteria.description),
211+
fields: ['description'],
212+
fuzziness: 'AUTO'
213+
}
214+
})
215+
}
203216
}
204217
if (criteria.forumId) {
205218
boolQuery.push({ match_phrase: { 'legacy.forumId': criteria.forumId } })

0 commit comments

Comments
 (0)