Closed Bug 731406 Opened 8 years ago Closed 8 years ago

Contacts API: Incremental Search

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: gwagner, Assigned: gwagner)

References

Details

Attachments

(1 file, 3 obsolete files)

Right now we have to iterate over all Contacts to perform incremental search.
The idea is to add a searchable field once we put a contact into the DB that allows to find the contact even with substrings.
For example "Tom" should be a findable with "t, to, tom, T, To, Tom"
Assignee: nobody → anygregor
Attached file WiP (obsolete) —
I added a search property to the contact in the DB that saves the text incrementally.
For example:
Something like: {givenName: "Tom", familyName: "Test"});

results in a DB object that looks like
properties: "givenName":["Tom"],"familyName":["Test"]
search: "givenName":["t","to","tom"],"familyName":["t","te","tes","test"]

I don't think it makes much sense to add a case sensitive incremental search.
Attached patch WiP (obsolete) — Splinter Review
Attachment #603480 - Attachment is obsolete: true
Attached patch patch (obsolete) — Splinter Review
Attachment #603481 - Attachment is obsolete: true
Attachment #603489 - Flags: review?(bent.mozilla)
You don't need to add multiple entries if you want to do just "prefix searching".

If someone searches for 't', just create a keyrange like

x = 't';
range = IDBKeyRange.bound(x, x + "\uFFFF");

That range will return all strings starting with 't'. Likewise if you set x to 'to' it'll find all strings starting with 'to'.

You will need to store a case-folded string though if you want case insensitive search. And do something like:

x = 'tO';
x = x.toLowerCase();
range = IDBKeyRange.bound(x, x + "\uFFFF");
Attached patch patchSplinter Review
Attachment #603489 - Attachment is obsolete: true
Attachment #603489 - Flags: review?(bent.mozilla)
Attachment #603803 - Flags: review?(bent.mozilla)
Comment on attachment 603803 [details] [diff] [review]
patch

Review of attachment 603803 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great!

::: dom/contacts/fallback/ContactDB.jsm
@@ +362,5 @@
>        if (key == "id") {
>          // store.get would return an object and not an array
>          request = store.getAll(options.filterValue);
>        } else {
> +        if (options.filterOp == "equals") {

Nit: could do 'else if' here

@@ +370,5 @@
> +          request = index.getAll(options.filterValue, options.filterLimit);
> +        } else {
> +          // not case sensitive
> +          let tmp = options.filterValue.toLowerCase();
> +          var range = this._global.IDBKeyRange.bound(tmp, tmp + "\uFFFF");

Nit: I'd consistently use 'let' here.
Attachment #603803 - Flags: review?(bent.mozilla) → review+
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/9e65814f61de
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Hi,

I wanted to report bug that TB can't seach based on second word in name, lastname or email fileds.
For example

Name: John Mary
Lastname: Smith
Email: john.mary.smith@email.com

If you search by "mary" TB will find nothing since that word is second in name field and not first in email field.
Did solving this bug fixed this also?

I'm using TB 10 ESR, not TB 14 so I cannot test it right now.
This bug has nothing to do with Thunderbird.  Please file a bug in the Thunderbird product or visit https://support.mozillamessaging.com/
Sorry, was doing search trought "file new bug" for Thunderbird and this came up.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.