While they're similar, they operate a little differently.
$search
uses Keyword Query Language (KQL) and is only supported by message
and person
collections (i.e. you can't use $search
on most endpoints). By default, it searches multiple properties. Most importantly, $search
is a "contains" search, meaning it will look for your search word/phrase anywhere within a string.
For example, /messages?$search="bacon"
will search for the word "bacon" anywhere in the from
, subject
, or body
properties.
Unlike $search
, the $filter
parameter only searches the specified property and does not support "contains" search. It also works with just about every endpoint. In most places, it supports the following operators: equals (eq
), not equals (ne
), greater than (gt
), greater than or equals (ge
), less than (lt
), less than or equals (le
), and (and
), or (or
), not (not
), and (on some endpoints) starts with (startsWith
).
For example, /messages?$filter=subject eq 'bacon'
will return only messages where the subject is "bacon".