Property Restrictions
In addition to Boolean operators,
wildcards, and other syntax operators, SharePoint 2010 users can
execute queries based on property restrictions to narrow the scope of a
search. Property restrictions allow users to limit results to those
that contain properties, or metadata, that they specify in the query.
In many cases, these properties may also be able to be restricted by
building the parameters in the Advanced Search page. If the option to
enter a property restriction has not been made available on the
Advanced Search page, however, manually building a restriction into the
query may be a user's only option for returning a specially refined
result set. Property restrictions can be executed for any managed
property value.
A basic property restriction is composed of the following components.
<Property Name> <Property Operator> <Property Value>
The property name is the particular
property being addressed, such as author, file type, or upload date.
The property operator is the symbol for the function a user wishes to
execute. Property operators are generally mathematical operators and
include functionality such as stating a property must be greater than,
less than, or equal to a value. A full list of these is provided later
in this section. Finally the property value is the numerical or written
language character that must be associated with the property. For
example, if the restriction is a date, the property value may be
September 30, or it could be .docx
in a file type restriction. These are a few examples of compiled keyword property restrictions.
author:"Josh Noble"
This returns only items authored by Josh Noble.
filetype:docx
This returns only Microsoft Word documents.
write>11/20/2010
This returns only items updated after 11/20/2010.
When building queries with property
restrictions, it is important not to leave any white space between
characters. As discussed in the section on Boolean operators, white
space is assumed by the search engine to be the AND or inclusion
character. As a result, the following queries would be treated as free
text queries instead of the intended property restriction.
author: "Josh Noble"
author :"Josh Noble"
author : "Josh Noble"
All three of these examples would yield results for the free text query.
author "Josh Noble"
As mentioned earlier, property restrictions can
be executed against any managed property. A secondary stipulation for
searching on a managed property is that the administrator must have set
the property to be either retrievable or full-text queryable. This is
not a property setting that can be made by the end user, but it does
affect the actions a user can perform on a managed property. Managed
properties that are set to be retrievable are soloed in the property
store database. Managed properties that are set to be full-text
queryable are stored in the full-text index along with all of the rest
of the content in a farm, such as sites, documents, and lists. As a
result, managed properties that are full-text queryable can accept the
same query syntax as a normal content query.
Only text properties, also called string
properties, can be set to be full-text queryable. All other managed
properties, such as numerical values (integers), dates, times, Boolean,
and binary data types, are strictly retrievable. Full-text queryable
properties can accept the full-range or keyword query operators.
author:Josh
author:Noble
For full-text queryable properties, both of
these property restrictions will return items authored by Josh Noble.
These properties can also accept suffix wildcard and exact phrase
operators.
author:Jos*
This example would return items authored by
Josh Noble as well as Joshua Hammond, Josef Smith, or Josline Heff if
the result set contains those authors. Just like keyword queries, the
wildcard operator can be used only at the end of a term. When the exact
phrase operator is used on a full-text queryable property, the property
must contain the specific phrase.
title:"SharePoint Expert"
title="SharePoint Expert"
In these examples, the document title must
contain the phrase “SharePoint Expert”. Returned results may include
“SharePoint Expert gives search advice”, “Become a SharePoint Expert”,
or “What the SharePoint Expert knows”. The suffix wildcard operator can
also be used in combination with the exact phrase operator.
title:"SharePoint Ex*"
This query would return items titled “The Best
SharePoint Experience”, “Who needs SharePoint Expertise?”, and
“SharePoint Express Search”.
Property values stored in the property database
can be queried only for the entire value of a property. Unlike free
text queryable properties, those that are just set to be retrievable
must match the property restriction query exactly. Again, this is not
an option made available to the end user, and if the settings of a
property are unknown, testing if something is set to retrievable,
full-text queryable, or both may require some trial and error. For
those that are only retrievable, and not also full-text queryable, the
following query would be accepted.
company:"APress Books"
This query would return only items in which the
company field is “APress Books”. Unlike full-text queryable properties,
if the company is “APress Books London”, the result would not be
returned. The term must match the field exactly. This same rule applies
for numerical property values such as integers, decimals, dates, times,
yes or no, and binary data types.
size:50MB
In this example, the returned results must have
exactly 50MB in the size property. The other property operators can
also be used against retrievable properties.
size<50MB
This property restriction returns only results in which the item size is less than 50MB.
size>=50MB
This property restriction returns only results
in which the item size is greater than or equal to 50MB. A full list of
the available operators can be found in Table 1.
Depending on the managed property being used, different operators can
be used. The table provides a full outline of the operators that can be
used for each data type. All of the listed operators can be used for
Integer, Decimal, and Datetime values. Text, or string, values can
accept the : or = operators. Binary and Boolean (YesNo) values can be
restricted only with the : operator.
Table 1. Property Restriction Operators
Operator |
Action |
: |
Results must contain the specified value. |
= |
Results must be equal to the value. |
> |
Results must be greater than the value. |
> = |
Results must be greater than or equal to the value. |
< |
Results must be less than the value. |
< = |
Results must be less than or equal to the value. |
< > |
Results do not equal the value. |
" |
Results must be within the range of the values. |
Although every environment will most likely
contain custom managed properties, a list of common managed properties
can be found in Table 2.
Table 2. Common Managed Properties
Property Name |
Description |
FileExtension File |
extension |
Filetype |
File type (same function as preceding) |
Author Author |
|
DocComments |
Comments |
DocKeywords Keywo |
rds |
FileName |
Item's file name e.g., docx or ppt |
Size |
File size in KB |
Path |
URL |
Write Last |
modified date |
CreatedBy Doc |
ument creator |
ModifiedBy Last |
modifier |
DocSubject Do |
cument subject |
Title Doc |
ument title |
It is also important to note that multiple
property restrictions can be combined to create a string of restriction
parameters in a keyword query. The length of a property restriction is
limited to 2,048 characters, but within that limit, combinations of
retrievable and free text queryable property restrictions can be
created. Users can string together restrictions for several different
properties and enter more than one restriction for each property.
When multiple values for the same property are
entered, the search engine treats them as if they were separated by the
OR Boolean operator.
author:"Josh Noble" author: "Robert Piddocke" author:"Dan Bakmand Mikalski"
This property restriction would return items
authored by “Josh Noble”, “Robert Piddocke”, or “Dan Bakmand Mikalski”.
It is important to remember that standard keyword queries automatically
use the AND operator, but the search engine assumes the OR operator
between identical property restrictions.
author:"Josh Noble" filetype=docx size>50MB
author:"Josh Noble AND filetype=docx AND size>50MB
Both of these queries will
return Microsoft Word documents that are larger than 50MB and authored
by Josh Noble. Just like a keyword query, the search engine
automatically enters the AND operator between restrictions for
different properties.
Finally, combinations of free text keyword queries and property restrictions can be entered as one query string.
Share* AND author:"Josh Noble" NOT "Piddocke"
This query would return items that contain the
keyword “Share”, are authored by Josh Noble, and do not contain the
phrase “Piddocke” within the content.
filetype=docx filetype=pdf AND "SharePoint Expert"
This query would return items that are either
Microsoft Word or PDF documents and contain the phrase “SharePoint
Expert”. Using the rules outlined in this section, a wide range of
advanced queries can be strung together to return a desired set of
search results. As users become more advanced, and the need to produce
more concise sets of search results increases, understanding the full
capabilities of this search syntax becomes increasingly necessary. A
full review of the available query syntax can be found in Table 3.
Table 3. Search Query Syntax Overview
Operator |
Example |
Prefix matching for search keywords and document properties using the wildcard * operator |
When searching for “nor*”, results may include “Norcross”, “north”, “normal”, etc. |
The “AND” operator specifies a result must include both terms separated by “AND”. |
When searching for “Noble AND SharePoint”, all results returned must contain both the term “Noble” and the term “SharePoint”. |
The “OR” operator specifies a result must
include at least one of the terms separated by “OR”, but does not need
to contain both. |
When searching for “Energy OR Nuclear”,
results will include items containing “Energy”, “Nuclear”, or both
“Energy” and “Nuclear”. |
The “WORDS” operator specifies that terms in a keyword query are synonyms. This is similar to the “OR” operator. |
When searching for WORDS (Kids,
Children), results will include items containing “Kids” as well as
“Children” and consider them to be the same term for ranking. |
The “NOT” operator specifies a result must not include the term following the “NOT” operator. |
When searching for “Energy NOT Nuclear”,
all results returned must contain the term “Energy”, but never should
contain “Nuclear”. |
The “-” (exclusion) operator works the same as the “NOT” operator. |
When searching for “Energy - Nuclear”,
all results returned must contain the term “Energy”, but exclude
results containing “Nuclear”. |
The “NEAR” operator specifies the adjacent search terms must be within close proximity to each other. |
When searching for “Energy NEAR Nuclear”,
all results returned will contain “Nuclear” within a limited number of
words after “Energy”. |
The use of quotation marks (“”) for designating exact search phrases is supported. |
The string “2009 financial report” will return all items that contain the exact phrase “2009 financial report”. |
Parentheses ( ) can be used to combine different parts of keyword queries and group search terms. |
The string “(Nuclear OR Oil) AND Energy”
will return all results containing “Energy” so long as they also
contain “Nuclear” or “Oil” terms as well. |
Property restrictions can be entered so that results match specific properties. |
The query “author:Josh Noble” will return
only documents authored by “Josh Noble”. “filetype:pdf” will return
only PDF-type files. |
Any combination of the foregoing search tools is supported. |
The query “plant AND
filetype:pdf” will return only PDF documents containing the term
“plant”. Also “instru* AND (author:Josh OR author:Dan)” will return all
items containing the term “instructions” authored by Josh or Dan. |