Multiple Filters

6 views
Skip to first unread message

Justin Richer

unread,
Apr 5, 2011, 11:46:08 AM4/5/11
to PortableContacts
We've recently had a request for presenting multiple filters on a
single request on our (internal) PoCo service. In particular, people
would like to filter on first name and last name to do fuzzy name-
search kind of stuff. The spec only defines a single set of filterBy/
filterOp/filterValue and the behavior if those are present. What I'm
wondering is how could we support multiple filters simultaneously, and
I've got a couple ideas of how to do it that I wanted to get feedback
from other folks.

The first idea is to just repeat the parameter, such as:

filterBy=name.familyName&filterOp=startswith&filterValue=ric&filterBy=name.givenName&filterOp=startswith&filterBy=jus

Within the processor, just take these as sets, in order to get two
successive filters:

filterBy=name.familyName
filterOp=startswith
filterValue=ric

filterBy=name.givenName
filterOp=startswith
filterBy=jus

This ends up giving us parallel arrays of data that we'd have to be
careful to parse appropriately. We'd also need to explicitly treat the
error conditions (such as five filterBys and only four filterOps) and
the order of filter application.

Another option would be to define some kind of demarcation to the
fields, such as comma separation in each field. This is fine for
filterBy and filterOp but falls over with filterValue, and it doesn't
solve the parallel-arrays issue above.

Has anybody figured out a way to do this yet?

-- Justin

Joseph Smarr

unread,
Apr 5, 2011, 2:16:19 PM4/5/11
to portable...@googlegroups.com
We considered allowing compound filtering, but decided against it for simplicity. You can always "chain" the output of one PoCo call as the input of another PoCo call (and then you get a second round of filtering), though this isn't always super efficient. You can see an example of this working at http://www.plaxo.com/pdata/pc2pcTest

If you just want to do fuzzy name matching, consider just implementing that when the user asks for filterBy=displayName or filterBy=name (or even just filterValue=xyz with no explicit filterBy set). As http://portablecontacts.net/draft-spec.html#anchor12 says, you have some flexibility in how you implement this, and a "it just works" approach may be simpler and more flexible for you (and your users) than making them explicitly pass in multiple filter operations.

Hope this helps!
Thanks, js


--
You received this message because you are subscribed to the Google Groups "PortableContacts" group.
To post to this group, send email to portable...@googlegroups.com.
To unsubscribe from this group, send email to portablecontac...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/portablecontacts?hl=en.


Daniel Chapman

unread,
Apr 10, 2011, 9:25:57 PM4/10/11
to portable...@googlegroups.com, jsm...@stanfordalumni.org
You could just handle the filter parameters as optional arrays.

If there is just one of each, then handle as usual.

If there is an array, handle it as a multiple.

No need to change the spec then, and anyone can implement it if they want it.
Reply all
Reply to author
Forward
0 new messages