Last Comment Bug 731406 - Contacts API: Incremental Search
: Contacts API: Incremental Search
Product: Core
Classification: Components
Component: DOM (show other bugs)
: unspecified
: x86 Mac OS X
-- normal (vote)
: mozilla14
Assigned To: Gregor Wagner [:gwagner]
: Andrew Overholt [:overholt]
Depends on:
Blocks: 674720
  Show dependency treegraph
Reported: 2012-02-28 14:15 PST by Gregor Wagner [:gwagner]
Modified: 2012-07-30 22:23 PDT (History)
7 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

WiP (17.83 KB, text/plain)
2012-03-06 14:54 PST, Gregor Wagner [:gwagner]
no flags Details
WiP (17.83 KB, patch)
2012-03-06 14:55 PST, Gregor Wagner [:gwagner]
no flags Details | Diff | Splinter Review
patch (15.22 KB, patch)
2012-03-06 15:35 PST, Gregor Wagner [:gwagner]
no flags Details | Diff | Splinter Review
patch (17.32 KB, patch)
2012-03-07 11:29 PST, Gregor Wagner [:gwagner]
bent.mozilla: review+
Details | Diff | Splinter Review

Description User image Gregor Wagner [:gwagner] 2012-02-28 14:15:36 PST
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"
Comment 1 User image Gregor Wagner [:gwagner] 2012-03-06 14:54:55 PST
Created attachment 603480 [details]

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.
Comment 2 User image Gregor Wagner [:gwagner] 2012-03-06 14:55:22 PST
Created attachment 603481 [details] [diff] [review]
Comment 3 User image Gregor Wagner [:gwagner] 2012-03-06 15:35:35 PST
Created attachment 603489 [details] [diff] [review]
Comment 4 User image Jonas Sicking (:sicking) No longer reading bugmail consistently 2012-03-06 18:47:25 PST
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");
Comment 5 User image Gregor Wagner [:gwagner] 2012-03-07 11:29:27 PST
Created attachment 603803 [details] [diff] [review]
Comment 6 User image Ben Turner (not reading bugmail, use the needinfo flag!) 2012-03-13 15:37:20 PDT
Comment on attachment 603803 [details] [diff] [review]

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.
Comment 8 User image Matt Brubeck (:mbrubeck) 2012-03-14 10:10:15 PDT
Comment 9 User image Mihovil Stanic [:Mikeyy - L10n HR] 2012-07-30 22:20:40 PDT

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

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.
Comment 10 User image Kyle Huey [:khuey] (Exited; not receiving bugmail, email if necessary) 2012-07-30 22:22:06 PDT
This bug has nothing to do with Thunderbird.  Please file a bug in the Thunderbird product or visit
Comment 11 User image Mihovil Stanic [:Mikeyy - L10n HR] 2012-07-30 22:23:29 PDT
Sorry, was doing search trought "file new bug" for Thunderbird and this came up.

Note You need to log in before you can comment on or make changes to this bug.