Contacts API: Incremental Search

RESOLVED FIXED in mozilla14

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: gwagner, Assigned: gwagner)

Tracking

unspecified
mozilla14
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 3 obsolete attachments)

17.32 KB, patch
Ben Turner (not reading bugmail, use the needinfo flag!)
: review+
Details | Diff | Splinter Review
(Assignee)

Description

5 years ago
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)

Updated

5 years ago
Assignee: nobody → anygregor
(Assignee)

Comment 1

5 years ago
Created attachment 603480 [details]
WiP

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.
(Assignee)

Comment 2

5 years ago
Created attachment 603481 [details] [diff] [review]
WiP
Attachment #603480 - Attachment is obsolete: true
(Assignee)

Comment 3

5 years ago
Created attachment 603489 [details] [diff] [review]
patch
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");
(Assignee)

Comment 5

5 years ago
Created attachment 603803 [details] [diff] [review]
patch
Attachment #603489 - Attachment is obsolete: true
Attachment #603489 - Flags: review?(bent.mozilla)
(Assignee)

Updated

5 years ago
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+
(Assignee)

Comment 7

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/9e65814f61de

Updated

5 years ago
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/9e65814f61de
Status: NEW → RESOLVED
Last Resolved: 5 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.
You need to log in before you can comment on or make changes to this bug.