Share via


SharePoint Foundation Search Keyword Syntax Inclusion and Exclusion

[This documentation is preliminary and is subject to change.]

When you specify the property filter in Microsoft SharePoint Foundation 2010 Search keyword syntax, you must also specify whether the results returned should include or exclude content that matches the value specified for that property filter. You accomplish this by using SharePoint Foundation 2010 Search keyword syntax inclusion and exclusion characters.

Inclusion and Exclusion Characters

The following table describes the keyword syntax inclusion and exclusion characters.

Name

Character

Behavior

Inclusion

"+"

Include content with values that match the inclusion.

Exclusion

"-"

Exclude content with values that match the exclusion.

Remarks

By definition, property filters are included, so you do not need to use the inclusion character "+". If you do include the character with a property filter, it is ignored. For example, the following syntax fragments behave similarly:

author:"John Smith"
+author:"John Smith"

You can use the exclusion character with a property filter to exclude results from search. This is equivalent to the NOT operator in SQL search syntax. The following syntax fragment shows the use of this character with a property filter:

-author:"John Smith"

Note The search query must contain at least one included keyword or property filter. If the query contains only an exclusion, it fails with a Microsoft.SharePoint.Search.Query.QueryContainsOnlyExcludedTermsExceptionexception.

See Also

Reference

Microsoft.SharePoint.Search.Query.KeywordQuery

SharePoint Foundation Search Keyword Syntax