How To Tame Windows 7 and Outlook Search Syntax–Knowing The Syntax Makes All The Difference


Search Simply Will Not Do What I Want It To Do!!!!

Almost ashamed to say I was looking for some file on my laptop but could not find the exact query set I needed to work with. I was looking for all of my Camtasia recording and project files. It was pretty easy to get all of any one of the types of files. All I had to do for that is search on the extension. In the case of Project files it was .camproj and in the case of recording files it was .camrec. If I entered either of these in the search from Windows-F or the top of Explorer it gave me all the files of that type. I really wanted to look at both the project files and the recording files in the same window so I could sort, compare dates, etc. Well, one would think this is a pretty easy task. I tried:

  1. .camrec => displayed all .camrec files
  2. .camproj => displayed all .camproj files
  3. .camrec, .camproj => no results
  4. .camrec or .camproj => no results
  5. “.camrec” “.camproj” => no results
  6. I think you get the picture… I tried many more things to get both files and none came up.

Now I really needed this list so I turned to Bing to find the answer. Yes, as expected, it was there. However it was buried beneath a few drill downs before I found what I was looking for. In an attempt for me to have easy access to the proper syntax of the Windows Search for Windows 7 and to provide you with the solution without having to do a bunch of digging, I decided to do a detailed blog post on Windows 7 Search Syntax.

 

It appears that Outlook 2010 syntax is the same as Windows 7 Search Smile

Windows 7 Syntax – Everything You Need To Know About Searching in Windows 7 Explorer or Windows 7 Search

 

For Starters Let me share the solution to my problem. I found the solution in an MSDN post on Advanced Query Syntax. I needed to use an “OR” between the two search phases. In my case I had to search on [ .camrec OR .camproj ] and YES the OR IS CASE SENSITIVE! Notice above I did try “or” but I had it lower case so it did not work. I guess it was looking for all three phrases which did not appear.

Now with that problem solved let’s look at the Windows 7 Syntax in Detail…

Desktop Search Syntax
A search query can include one or more keywords, with Boolean operators and optional criteria. These optional criteria can narrow a search based on the following:

  • Scope or data store in which files reside
  • Kinds of files
  • Managed properties of files

The optional criteria, described in greater detail following, use the following syntax:

  • <scope name>:<value>
  • <file kind>:<value>
  • <property name>:<value>

Suppose a user wants to search for a document containing the phase “last quarter,” created by John or Joanne, and that the user saved to the folder mydocuments. The query may look like this:

"last quarter" author:(john OR joanne) foldername:mydocuments

 
Scope: Locations and Data Stores
Restrict Search by Data Store Use Example Syntax
Desktop desktop store:desktop
Files files store:files
Outlook outlook store:outlook
Outlook Express oe store:oe
Specific Folder foldername or in foldername:MyDocuments or in:MyDocuments
 
Common File Kinds

Users can also limit their searches to specific types of files, called file kinds. The following table lists the file kinds and offers examples of the syntax used to search for these kinds of files.

To Restrict by File Type: Use Example Syntax
All file types everything kind:everything
Communications communications kind:communications
Contacts contacts kind:contacts
E-mail email kind:email
Instant Messenger conversations im kind:im
Meetings meetings kind:meetings
Tasks tasks kind:tasks
Notes notes kind:notes
Documents docs kind:docs
Text documents text kind:text
Spreadsheets spreadsheets kind:spreadsheets
Presentations presentations kind:presentations
Music music kind:music
Pictures pics kind:pics
Videos videos kind:videos
Folders folders kind:folders
Folder name foldername or in foldername:mydocs or in:mydocs
Favorites favorites kind:favorites
Programs programs kind:programs
 
Properties by File Kind

Users can search on specific properties of different file kinds. Some properties (like file size) are common to all files, while others are limited to a specific kind. Slide count, for example, is specific to presentations. The following tables list these properties by file kind.

File Kind: Everything

These are properties common to all file kinds. To include all types of files in a query, the syntax is:

kind:everything <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
Title title, subject or about title:”Quarterly Financial”
Status status status:complete
Date date date:last week
Date modified datemodified or modified modified:last week
Importance importance or priority importance:high
Size size size:> 50
Deleted deleted or isdeleted isdeleted:true
Is attachment isattachment isattachment:true
To to or toname to:bob
Cc cc or ccname cc:john
Company company company:Microsoft
Location location location:”Conference Room 102″
Category category category:Business
Keywords keywords keywords:”sales projections”
Album album album:”Fly by Night”
File name filename or file filename:MyResume
Genre genre genre:rock
Author author or by author:”Stephen King”
People people or with with:(sonja or david)
Folder folder, under or path folder:downloads
File extension ext or fileext ext:.txt
 
Boolean Operators

Search keywords and file properties can be combined to broaden or narrow a search with operators. The following table explains common operators used in a search query.

LOOK => This is the one that solved my problem Smile

Note

The operators AND, NOT and OR must be in uppercase and cannot be combined in one query (e.g., social OR security NOT retirement).

Keyword/Symbol Examples Syntax Function
NOT social NOT security Finds items that contain social, but not security.
social –security Finds items that contain social, but not security.
OR social OR security Finds items that contain social or security.
AND social AND security Finds items with social AND security
Quotation marks “social security” Finds items that contain the exact phrase social security.
Parentheses (social security) Finds items that contain social and security in any order.
> date:>11/05/04

size:>500

Finds items with a date after 11/05/04.

Finds items with a size greater than 500 bytes.

< date:<11/05/04

size:<500

Finds items with a date before 11/05/04.

Finds items with a size less than 500 bytes.

.. date:11/05/04..11/10/04 Finds items with a date beginning on 11/05/04 and ending on 11/10/04.
 
Dates

In addition to searching on specific dates and date ranges using the operators described earlier, AQS allows relative date values (like today, tomorrow, or next week) and day (like Tuesday or Monday..Wednesday) and month (February) values.

Date Ranges

specify a date range, type the property followed by two dates. For example, type from:david sent:11/05/06..11/05/07. Windows Search recognizes all Windows date formats and also recognizes the following values:

  • Relative dates: Today, tomorrow, yesterday
  • Multi-word relative dates: week, next month, last week, past month, or coming year. The values can also be entered contracted, as follows: thisweek, nextmonth, lastweek, pastmonth, comingyear.
  • Days: Sunday, Monday … Saturday
  • Months: January, February … December
Relative to: Syntax Example Result
Day date:today

date:tomorrow

date:yesterday

Finds items with today’s date.

Finds items with tomorrow’s date.

Finds items with yesterday’s date.

Week/Month/year date:this week

date:last week

date:next month

date:past month

date:coming year

Finds items with a date falling within the current week.

Finds items with a date falling within the previous week.

Finds items with a date falling within the upcoming week.

Finds items with a date falling within the previous month.

Finds items with a date falling within the upcoming year.

  date:>2/7/05<2/10/05 Searches for a date in the Date property between the values 2/7/05 and 2/10/05, excluding the end dates.
  date:>=2/7/05<=2/10/05 Searches for a date in the Date property between the values 2/7/05 and 2/10/05, including the end dates.
  date:2/7/05 .. 2/10/05 Same as date:>=2/7/05<=2/10/05
 
Size
Use Example Syntax
Searches for files with a value in the Size between50 KB and 70 KB, excluding the end values. size:>50KB <70KB
Searches for files with a value in the Size property between 50 KB and 70 KB, including the end values. size:>=50KB <=70KB
Same as size:>=50KB <=70KB size:50KB..70KB
 
     
Attachment

These are properties common to attachments. To limit the search to attachments only, the syntax is:

kind:attachment <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
People people or with people:john or with:john
 
Contacts

These are properties common to contacts. To limit the search to contacts only, the syntax is:

kind:contacts <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

 

Note

Phone numbers are indexed as entered. For example, if a user did not include a country or area code when entering the phone number, users will not be able to locate a contact if searching with country or area code in the phone number.

Property Use Example Syntax
Job title jobtitle jobtitle:CFO
IM address imaddress imaddress:john_doe@msn.com
Assistant’s phone assistantsphone assistantsphone:555-3323
Assistant name assistantname assistantname:Paul
Profession profession profession:plumber
Nickname nickname nickname:Tex
Spouse spouse spouse:Debbie
Business city businesscity businesscity:Seattle
Business postal code businesspostalcode businesspostalcode:98006
Business home page businesshomepage businesshomepage:www.microsoft.com
Callback phone number callbackphonenumber callbackphonenumber:555-555-2121
Car phone carphone carphone:555-555-2121
Children children children:Timmy
First name firstname firstname:John
Last name lastname lastname:Doe
Home fax homefax homefax:555-555-2121
Manager’s name managersname managersname:John
Pager pager pager:555-555-2121
Business phone businessphone businessphone:555-555-2121
Home phone homephone homephone:555-555-2121
Mobile phone mobilephone mobilephone:555-555-2121
Office office office:sample
Anniversary anniversary anniversary:1/1/06
Birthday birthday birthday:1/1/06
Web page webpage webpage:www.microsoft.com
 
Communications

These are properties common to communications. To limit the search to communications only, the syntax is:

kind:communications <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
From from or organizer from:john
Received received or sent sent:yesterday
Subject subject or title subject:”Quarterly Financial”
Has attachment hasattachments, hasattachment hasattachment:true
Attachments attachments or attachment attachment:presentation.ppt
Bcc bcc, bccname or bccaddress bcc:dave
Cc address ccaddress or cc ccaddress:john_doe@hotmail.com
Follow-up flag followupflag followupflag:2
Due date duedate or due due:last week
Read read or isread is:read
Is completed iscompleted is:completed
Incomplete incomplete or isincomplete is:incomplete
Has flag hasflag or isflagged has:flag
Duration duration duration:> 50
 
Calendar

These are properties common to calendars. To limit the search to calendars only, the syntax is:

kind:calendar <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
Recurring recurring or isrecurring is:recurring
Organizer organizer, by or from organizer:debbie
 
Documents

These are properties common to documents. To limit the search to documents only, the syntax is:

kind:documents <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
Comments comments comments:”needs final review”
Last saved by lastsavedby lastsavedby:john
Document manager documentmanager documentmanager:john
Revision number revisionnumber revisionnumber:1.0.3
Document format documentformat documentformat:MIMETYPE
Date last printed datelastprinted datelastprinted:last week
 
Presentation

These are properties common to presentations. To limit the search to presentations only, the syntax is:

kind:presentation <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
Slide count slidecount slidecount:>20
 
Music

These are properties common to music files. To limit the search to music only, the syntax is:

kind:music <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
Bit rate bitrate, rate bitrate:192
Artist artist, by or from artist:John Singer
Duration duration duration:3
Album album album:”greatest hits”
Genre genre genre:rock
Track track track:12
Year year year:> 1980 < 1990
 
Picture

These are properties common to pictures. To limit the search to pictures only, the syntax is:

kind:picture <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
Camera make cameramake cameramake:sample
Camera model cameramodel cameramodel:sample
Dimensions dimensions dimensions:8X10
Orientation orientation orientation:landscape
Date taken datetaken datetaken:yesterday
Width width width:1600
Height height height:1200
 
Video

These are properties common to videos. To limit the search to videos only, the syntax is:

kind:video <property>:<value>

where <property> is a property listed below and <value> is the user-specified search term.

Property Use Example Syntax
Name name, subject name:”Family Vacation to the Beach 05″
Ext ext, fileext ext:.avi
 
     
     

There is a Windows Search Overview page at: Windows Search Overview

More information available for using Advance Query Syntax Programmatically at Using Advanced Query Syntax Programmatically