Searching and the Partialmatch filter

Showing 1-5 of 5 messages
Searching and the Partialmatch filter anselmdk 10/14/12 6:05 AM
I'm writig a small search form to search for a specific page type on the frontend.
In the documentation ( it's mentioned that you can write something like below, when you want to search for more than one field:

$members = Member::get()->filter(array(
    'FirstName,Surname:PartialMatch' => 'sam'

Running this on both master and the 3.0 branch gives the error "Couldn't find field FirstName,Surname in any of Member's tables.".
I've dug a little into the problem, and see that the constructor of SearchFilter.php (which PartialmatchFilter.php extends) is internally setting "fullName" to "FirstName,Surname" instead of checking whether it's dealing with a list and converting it to an array (and then doing it's magic).

Rather than being a bug it seems to me that this feature has just not been implemented yet?


Re: Searching and the Partialmatch filter Ingo Schommer 10/16/12 6:10 AM
I've confirmed that its not possible to do this,
and think this was documentation-driven development getting a bit out of hand.
Removed the paragraph for now, until its fixed or decided not worth implementing.
I think its an unnecessary duplication of the existing array syntax (paragraph above),
and makes the API both more ambiguous for users, as well as harder to handle inputs internally.
Sorry for the confusion.

Re: [silverstripe-dev] Searching and the Partialmatch filter anselmdk 10/16/12 6:47 AM
Hi Ingo,
thanks for checking up on this.
Maybe I'm getting things wrong, but I think there is no other way of doing it with the new ORM (or at least no documented way).

I just checked up with the following example. Let's say I'm searching for "$query = New York", and there is a dataobject with a City attribute that has the value "New York". This code returns nothing:

$projects = $projects->filter(array(
'Title:PartialMatch' => $query,
'City:PartialMatch' => $query,

If I'm uncommenting the Title part, I'm getting the dataobject with the city "New York", which leads me to conclude that this is an AND statement. 
What I was looking for was an OR statement, which I believe the previous example would have given.
Maybe I'm missing something?

I got around it using the "where" method. Here is how I did for a small search functioniality:

$query = strtolower(addslashes($query)); $qarr = preg_split('/[ +]/', $query); $filter = ''; $first = true; foreach ($qarr as $qitem) { if (!$first) { $filter .= " AND "; } $filter .= " ( Title LIKE '%$qitem%' OR City LIKE '%$qitem%' )"; $first = false; } $projects = $projects->where($filter);

Again, forgive me if I should have missed something obvious in the documentation, but I believe there might be no way of writing OR statements with the partialmatch filter.


You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Re: [silverstripe-dev] Searching and the Partialmatch filter Ingo Schommer 10/16/12 7:02 AM
Yep, filter() works with AND conjunctives.
The lack of a way to do OR disjunctives through the ORM was
a major API omission in 3.0, but alas, we're getting there…
Re: [silverstripe-dev] Searching and the Partialmatch filter anselmdk 10/16/12 7:16 AM
Awesome :)