Friday, January 11, 2013

Write effective queries for SharePoint Search

Whether you search from a site or the Search Center constructing an effective query can result in quickly finding the information you want. You can use a combination of free text, phrases, logical operators, and property-based restrictions look for information or people.
Here are some things to keep in mind when writing a query:
  • Separate search terms with spaces The search results will list all content containing all of the words in any order.
  • Search ignores capitalization A search for Author:John has the same results as a search for author:john.
  • Use quotation marks for exact results When you are sure that the document you want contains the exact words in the exact order of your query, put the query in quotes. Otherwise, it is best to leave the phrase unquoted. For example, a query for this article, Search for content will find only those articles where "search" AND "content" are together.
  • Number of characters A query must be no longer than 255 characters.

Add Boolean logic to a query

Now that you know about the basics of search, you might want to add some parameters to make your search results more specific. SharePoint allows you to use Boolean logic to keywords and properties, which means connecting them with the operators AND, OR, NOT, + (PLUS), and - (MINUS) to construct a meaningful query. Use the following examples to help create successful queries.
Logical operatorDescription and example
ANDUse to find all words documents, regardless of their relationship. For example, apples AND oranges finds all documents containing both apples and oranges, but the two terms might not be concurrent in the documents.
ORUse OR to find all documents containing either word or words. For example, a search for C++ OR C# finds all documents containing either of those programming languages.
NOTUse NOT to exclude certain results. For example, marketing AND forecast NOT budget will return documents containing the keywords marketing and forecast, but not budget.
+ (PLUS)The query SharePoint+Excel will return all documents containing both keywords.
- (MINUS)The query SharePoint+Excel -Excel 2007 -Excel 2003 will return all documents containing keywords Excel 2003 and Excel 2007.
In addition to logical operators, SharePoint allows the use of relational operators. You can construct a query by using the following values:
Relational operatorDescription and example
: ColonUse with a property to specify equality. For example, Author:Smith means the author equals Smith.
= Equal toUse with a property to specify equality. For example, Author:Smith means the author equals Smith.
< Less thanUse with dates and integers to specify less than. For example, search specs modified<7 b="b"> will return all search specifications that were modified before July 8, 2009.
> Greater thanUse with dates and integers to specify greater than. For example, search specs modified>7/8/09 will return all search specifications that were modified after July 8, 2009.
<= Less than or equal to Use with dates and integers to specify less than or equal to. For example, search specs modified<=7/8/09 will return all search specifications that were modified before July 8, 2009 inclusive.
>= Greater than or equal to Use with dates and integers to specify greater than or equal to. For example, search specs modified>=7/8/09 will return all search specifications that were modified after July 8, 2009 inclusive.
.. two dotsFor example, property: value 1..value 2 indicates that the property is greater than or equal to value 1 and less than or equal to value 2.
<> (not equal to)Use with dates and integers to exclude. For example, search specs modified<>7/8/09 will return all search specifications that were not modified on July 8, 2009.

Query using properties

You can construct queries using properties, which are the metadata on documents saved in SharePoint. The author of a document or the date it was saved is an example of a property. Content properties and their values are stored when sites are indexed. When you have specific information about the properties of an item, you can use it to help construct a query to find the item.
When you create a search using properties, do not use spaces between the property and the value.
Search on property valuesUse the syntax property:value. For example, author:smith finds all documents authored by a person whose name is Smith.
Search by filenameType filename:"Budget" (with quotation marks) to find a file named "Budget.xlsx," or type filename:budget (without quotation marks) to find both "Budget_Current.xlsx" and "Budget_Next.xlsx."
Search by file typeSuppose that you are looking for budget spreadsheets that were prepared in Excel 2007. Append filetype:xlsx to your query to display only search results that are Excel 2007 workbooks.
WildcardsUse an asterisk "*" for a prefix match with a keyword or property to find documents. For example, a search for Author:Smi will return all documents written by an author whose name begins with the letters Smi.
Search on different propertiesThe search service interprets the space between terms that use different properties as an AND. For example, if you search on title:budget filetype:xlsx, your search will return only Excel 2007 workbooks with titles that begin with the word "Budget."
Exclude certain search resultsTo exclude search results that contain certain terms, use a minus sign (-) before the term that you want to exclude. For example, if you want to find items that include the word "expenses" but do not include the word "taxes," type expenses -taxes in the Search box.
Append file propertiesUse properties to specify the name or type of file to return. For example, if you want to find Microsoft Office Word 2007 files that include the word "schedule," type schedule filetype:docx in the Search box.
Search for alternate values for the same propertyThe search service interprets the space between terms that use the same property as an OR. For example, if you search on author:"John Smith" author:"David Jones", your search will return items that were created by either person.
Exclude property valuesTo exclude content that is marked with a certain property value, use a minus sign (-) before the name of the property.
Focus on a particular serverIf the site property is available for searches, you can append site:servername to your query to focus your search on content that is stored on a particular server.
Note Backslash characters (\) do not work in queries. Therefore, do not use backslashes for a server path when you type the site:\\servername.
Date/time Any date/time property in any format can be used with relational or logical operators to form a query. For example, search specs modified=7/8/09 will return all search specifications that were modified on July 8, 2009.
Notes
A query must include at least one term to find. Queries that consist only of terms to exclude will produce an error message.
If your administrator has mapped properties such as writer or e-mail to the managed property author, your results might also include content that contains these properties.
If you cannot find documents that you know are in your organization, you may need to work with your search services administrator to have the documents added to the search index, enable permissions on the documents, or add or change keywords or properties for the documents.

No comments:

Post a Comment