Page MenuHomePhabricator

[lib] Introduce SentencePrefixSearchIndex
ClosedPublic

Authored by patryk on Aug 22 2023, 2:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 9:30 PM
Unknown Object (File)
Wed, Nov 20, 2:39 AM
Unknown Object (File)
Wed, Nov 20, 12:26 AM
Unknown Object (File)
Mon, Nov 18, 5:41 PM
Unknown Object (File)
Sat, Nov 9, 4:59 PM
Unknown Object (File)
Sat, Nov 9, 4:58 PM
Unknown Object (File)
Sat, Nov 9, 1:46 PM
Unknown Object (File)
Sat, Nov 9, 1:46 PM
Subscribers

Details

Summary

Solution for ENG-4556.

This diff introduces new SearchIndex class which operates on text prefixes rather than on keywords.

Depends on D8898.

Test Plan

Tested later in the stack.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

patryk held this revision as a draft.
patryk edited the test plan for this revision. (Show Details)
patryk added reviewers: tomek, inka.
patryk edited the summary of this revision. (Show Details)

Remove useless code

patryk added inline comments.
lib/shared/sentence-prefix-search-index.js
10

new Tokenizer().words() removes punctuation from keywords, chat names can include them so we need to keep them.

13–19

How does this work? Rather than storing kewords, we store whole prefixes. Let's take "test chat" name as an example. SearchIndex would store only keywords prefixes:

  • t, te, tes, test
  • c, ch, cha, chat

Using this approach would eventually hide our typeahead tooltip when user would press the space and that's not what we want while typing chat name in input bar while mentioning. New SearchIndex entries look like this:

  • t, te, tes, test, "test ", test c, ..., test chat
  • c, ch, cha, chat
This revision is now accepted and ready to land.Aug 28 2023, 8:10 AM
lib/shared/search-index.js
29 ↗(On Diff #30287)

Not sure if handler is the right name. How about e.g. addAllPrefixes?

lib/shared/sentence-prefix-search-index.js
25–31 ↗(On Diff #30287)

This can be simplified

Rename addEntryHandler to addAllPrefixes and simplify code