Page MenuHomePhabricator

[kayserver] Fix search endpoint failing when called with a stopword
ClosedPublic

Authored by inka on Jun 7 2023, 6:45 AM.
Tags
None
Referenced Files
F6181002: D8144.id27524.diff
Wed, Apr 23, 6:19 AM
F6167052: D8144.id.diff
Wed, Apr 23, 12:43 AM
F6165844: D8144.id27652.diff
Tue, Apr 22, 11:28 PM
Unknown Object (File)
Tue, Apr 22, 11:40 AM
Unknown Object (File)
Fri, Apr 18, 6:53 AM
Unknown Object (File)
Sat, Apr 12, 6:00 PM
Unknown Object (File)
Fri, Apr 4, 2:03 AM
Unknown Object (File)
Thu, Apr 3, 10:03 AM
Subscribers

Details

Summary

issue: https://linear.app/comm/issue/ENG-4055/search-endpoint-failing-when-called-with-only-a-stopword
When searchMessagesInSingleChat was passed a string with only stopwords, they were stripped away by processQueryForSearch and the pattern variable was '+', which is not a valid patter for MATCH AGAINST query

Test Plan

call the endpoint with a string that had only stopwords, checked that there are no errors. Called the endpoint with a string containing both a stopword and a non stopword, checked that it returns correct values. Checked he endpoint with a string containing only a non stopword.

Diff Detail

Repository
rCOMM Comm
Branch
inka/validate_endpoint
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

inka edited the test plan for this revision. (Show Details)

I could also just check if pattern === '+' and not change the processQueryForSearch function, but I like this approach better

inka requested review of this revision.Jun 7 2023, 7:02 AM
kamil added inline comments.
keyserver/src/database/search-utils.js
139

maybe worth adding a test case with something like: expect(processQueryForSearch(stopWord)).toBe('');

This revision is now accepted and ready to land.Jun 12 2023, 1:27 AM