- From: <richard.tibbett@orange-ftgroup.com>
- Date: Tue, 13 Oct 2009 18:21:58 +0200
- To: <anssi.kostiainen@nokia.com>
- Cc: <brian@westcoastlogic.com>, <public-device-apis@w3.org>
On 13th Oct, 2009 3:01pm, anssi.kostiainen@nokia.com wrote:
>
> On 9.10.2009, at 17.12, ext richard.tibbett@orange-ftgroup.com wrote:
>
> > On 7th Oct, 2009 10:41am, anssi.kostiainen@nokia.com wrote:
> >> I'd also add:
> >>
> >> MAY provide an interface to search through contacts.
> >
> > Taking the use cases from my previous email and with the assumption
> > that 'within each Contact object the fields are ANDed' and 'between
> > Contact objects the fields are ORed' then this could be
> accomplished
> > using sequences of ContactFilter objects as follows:
> >
> > 1. Filter contacts that are in my ('friends' OR
> 'collegues') group AND
> > are based in the 'UK'.
> >
> > var search = {
> > { category: 'friends', country: 'uk' },
> > { category: 'colleagues', country: 'uk' }
> > };
> >
> > /*...*/device.contacts.addressbook.find(search);
> >
> > 2. Search for the entered query string 'london' over any of the
> > following contact attributes: 'firstname', 'lastname', 'address',
> > 'job'
> > and return all matching results.
> >
> > var search = {
> > { firstname: 'london' },
> > { lastname: 'london' },
> > { address: 'london' },
> > { job: 'london' }
> > };
> >
> > /*...*/device.contacts.addressbook.find(search);
> >
>
> Looks like a fairly intuitive subset of a JavaScript-ish
> query language. Granted, it's easy to start sliding into the
> direction of specifying a full-blown query language but let's
> stop here. I feel the proposal above (=support for AND and OR
> operators) fulfills the following requirement by striking a
> balance between simplicity and functionality (perhaps a bit
> on the expense of extensibility):
>
> "SHOULD enable filtering the list of contacts to search for a subset"
>
I agree. I also wanted to stay away from a full-blown query language. I
saw an easy win to get more powerful search based on simple AND/OR
rules.
If there is a better, more Javascript-ish, way to represent this ANDing
and ORing structure then that would be welcome. The proposed structure
is hopefully fairly intuitive and brings a lot more query-like search
functionality to the API with minimal impact on the API.
> Btw. I assume the search variable should be of type Array in
> the above examples?
>
Yep. Unless I put code through a browser I tend to hash the syntax and
end up with something semi-pseudo ;-)
The outer curly braces should be replaced with square brackets above to
indicate an Array type (and that Array is full of plain Javascript
objects representing ContactFilters).
> > Does that provide the search feature required? This would
> denote only
> > the following minimal change to the existing Contacts API
> WebIDL (plus
> > some descriptive text):
> >
> > [NoInterfaceObject]
> > interface AddressBook {
> > ...
> > sequence<Contact> find (in Object filter); };
> >
>
> The find method should perhaps be described as something like
> (reflecting the latest Contacts API ED):
>
> sequence<Contact> find (in sequence<ContactFilter> filters);
>
Suggesting Object was to allow for one ContactFilter to be passed OR a
sequence of ContactFilter objects to be passed, effectively allowing
represention of 1 or n ContactFilters. Having said that, your proposal
is simpler and consistent, though an Array object will always be
required, even for just a single ContactFilter object. I should have
explained the rational for Object in my original email. I can live with
either proposal.
Thanks,
Richard
Received on Tuesday, 13 October 2009 16:22:41 UTC