Advanced Query Syntax
The Advanced Query Syntax (AQS) is used by Windows Search to help users and programmers better define and narrow their searches. Using AQS is an easy way to narrow searches and deliver better result sets. Searches can be narrowed by the following parameters:
- File kinds: folders, documents, presentations, pictures and so on
- Data stores: specific databases and locations
- Properties: size, date, title and so on
- Contents: text like "project deliverables" or "blue suede shoes"
Note Windows Search indexes text content but not punctuation.
Furthermore, search parameters can be combined using search operators. The remainder of this section explains the query syntax, the parameters and operators, and how they can be combined to offer targeted search results. The tables describe the syntax to use with Windows Search, as well as the properties that can be queried for each file kind displayed in the Windows Search results window.
About AQS 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
A search query, including optional criteria described in greater detail following, has the following syntax:
[<search string>] [<scope>:<value>] [<file kind>:<value>] [<property name>:<value>]
Suppose a user wants to search for a document containing the phase "last quarter," created by Theresa or Lee, and that the user saved to the folder MyDocs. The query may look like this:
"last quarter" author:(theresa OR lee) folder:MyDocs
Scope: Locations and Data Stores
Users can limit the scope of their searches to specific folder locations or data stores. For example, if you use several e-mail accounts and you want to limit a query to either Microsoft Outlook or Outlook Express, you can use store:mapi or store:oe respectively.
| Restrict Search by Data Store | Use | Example |
|---|
| Files | file | store:file |
| Outlook | mapi | store:mapi |
| Outlook Express | oe | store:oe |
| Offline files | csc | store:csc |
| Specific folder on local drive | folder | folder:C:\MyFolder |
If you have a protocol handler in place to crawl custom stores, like Lotus Notes, you can use the name of the store or protocol handler for the store. For example, if you implemented a protocol handler to include a Lotus Notes data store as "notes," the query syntax would be store:notes.
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.
| Keyword/Symbol | Examples | Function |
|---|
| NOT | social NOT security | Finds items that contain social, but not security. |
| – | social –security | Finds items that contain social, but not security. |
| AND | social AND security | Finds items that contain both social and security. |
| + | social + security | Finds items that contain both social and security. |
| OR | social OR security | Finds items that contain social or 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. |
| Empty braces [] | tags:=[] | Finds items that have no value for a specified property. In this example, finds all items have not been tagged. |
| > | 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. |
Note The operators NOT, AND and OR must be in uppercase
Boolean Properties
Some file types let users search for files using Boolean properties, as described in the following table.
| Property | Example | Description |
|---|
| is:attachment | report is:attachment | Finds items that have attachments that contain report. Same as isattachment:true. |
| isonline: | report isonline:true | Finds items that are online and which contain report. |
| isrecurring: | report isrecurring:true | Finds items that are recurring and which contain report. |
| isflagged: | report isflagged:true | Finds items that are flagged (Review, Follow up, for example) and which contain report. |
| isdeleted: | report isdeleted:true | Finds items that are flagged as deleted (Recycle Bin or Deleted Items, for example) and which contain report. |
| iscompleted: | report iscompleted:false | Finds items that are not flagged as complete and which contain report. |
| hasattachment: | report hasattachment:true | Finds items containing report and having attachments |
| hasflag: | report hasflag:true | Finds items containing report and having flags. |
Wildcards
You can use the familiar ? and * wildcard characters in queries.
| Wildcard | Example | Description |
|---|
| ? | M?crosoft | Matches one arbitrary character. |
| * | M*soft, Micro* | Matches any number of characters. |
Characters
In addition to using wildcard characters in queries, you can do character based searches in specific properties.
| Property | Example | Description |
|---|
| ~< | ~<abc | For Windows 7 and later. Searches for items where the property value begins with abc. |
| ~> | ~>abc | For Windows 7 and later. Searches for items where the property value ends with abc. |
| ~~ | ~~abc | For Windows 7 and later. Searches for items where the property value contains abc. |
| ~*? | ~*a?c | Searches for items where the property value matches the pattern *a?c (where * and ? are wildcards). |
For example:
- subject:~~9032663700002 can be used to find a message with 209032663700002001 in the subject.
- System.search.Autosummary:~~9032663700002 can be used to find all occurances of Autosummary which contain this string.
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.
| 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.
|
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 |
|---|
| Communications | communications | kind:communications |
| Contacts | contacts, person | kind:contacts kind:person |
| 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 |
| Music | music, song | kind:music kind:song |
| Pictures | pics, pictures | kind:pics |
| Videos | videos | kind:videos |
| Folders | folders | kind:folders |
| Folder name | folder | folder:C:\MyFolder |
| Programs | programs | kind:programs |
| Recorded TV | tv | kind:tv |
| Link | link | kind:link |
| Journal entry | journal | kind:journal |
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 documents. The following tables list these properties by file kind.
You can search for null values in properties using empty brackets (for exmaple, subject:[]) or for all non-null values in properties (for example, -subject:[]).
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 |
|---|
| Album | album | album:"Hail to the Thief" |
| Author | author, by | author:Doug |
| Category | category | category:Business |
| Cc | cc, ccname | cc:Sherri |
| Company | company | company:Microsoft |
| Date | date | date:last week |
| Date modified | datemodified, modified | modified:last week |
| Deleted | deleted, isdeleted | isdeleted:true |
| File extension | ext, fileext | ext:.txt |
| File name | filename, file | filename:MyResume |
| Folder | folder, under, path | folder:downloads |
| Genre | genre | genre:rock |
| Importance | importance, priority | importance:high |
| Is attachment | isattachment | isattachment:true |
| Keywords | keywords | keywords:"sales projections" |
| Location | location | location:"Conference Room 102" |
| Size | size | size:> 50 |
| Status | status | status:complete |
| Tags | tag, keyword | tag:personal |
| Title | title, subject, about | title:"Quarterly Financial" |
| To | to, toname | to:Fred |
| Type | type | type:image |
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.
| Property | Use | Example |
|---|
| Anniversary | anniversary | anniversary:1/1/06 |
| Assistant name | assistantname | assistantname:Halle |
| Assistant's phone | assistantsphone | assistantsphone:555-3323 |
| Birthday | birthday | birthday:1/1/06 |
| Business city | businesscity | businesscity:Seattle |
| Business postal code | businesspostalcode | businesspostalcode:98006 |
| Business home page | businesshomepage | businesshomepage:www.microsoft.com |
| Business phone | businessphone | businessphone:555-555-2121 |
| Callback phone number | callbacknumber | callbacknumber:555-555-2121 |
| Car phone | carphone | carphone:555-555-2121 |
| Children | children | children:Henry |
| IM address | imaddress | imaddress:john_doe@msn.com |
| Home fax | homefax | homefax:555-555-2121 |
| Home phone | homephone | homephone:555-555-2121 |
| Job title | jobtitle | jobtitle:CFO |
| Nickname | nickname | nickname:Jack |
| First name | firstname | firstname:Jackson |
| Last name | lastname | lastname:Marshall |
| Mobile phone | mobilephone | mobilephone:555-555-2121 |
| Office | officelocation | officelocation:BldgA/Rm101 |
| Pager | pager | pager:555-555-2121 |
| Profession | profession | profession:plumber |
| Spouse | spouse | spouse:Yvette |
| Manager's name | manager | manager:Theresa |
| Web page | webpage | webpage:www.microsoft.com |
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.
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 |
|---|
| Attachments | attachments, attachment | attachment:presentation.ppt |
| Bcc | bcc, bccname, bccaddress | bcc:Ian |
| Cc address | ccaddress, cc | cc:Chris |
| Duration | duration | duration:> 120 |
| Due date | duedate, due | due:last week |
| Follow-up flag | flagstatus | flagstatus:unflagged flagstatus:followup flagstatus:completed |
| From | from, organizer | from:Vicki |
| Incomplete | incomplete | incomplete:true |
| Is completed | iscompleted | iscompleted:true |
| Has attachment | hasattachments, hasattachment | hasattachment:true |
| Has flag | has:flag, isflagged | has:flag isflagged:true |
| Received | received, sent | sent:yesterday |
| Read | read, isread | isread:false |
| Subject | subject, title | subject:"Quarterly Financial" |
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 |
|---|
| Location | location | location:ConfRoomA |
| Organizer | organizer, by, from | organizer:Nancy |
| Recurring | recurring, is:recurring | is:recurring recurring:true |
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 |
|---|
| Comments | comments | comments:"needs final review" |
| Date last printed | datelastprinted | datelastprinted:last week |
| Document manager | documentmanager | documentmanager:LeAnne |
| Last saved by | lastsavedby | lastsavedby:Carl |
| Revision number | revisionnumber | revisionnumber:1.0.3 |
| Slide count | slides | slides:>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 |
|---|
| Artist | artist, by | artist:"Golden Palominos" |
| Album | album | album:"Greatest Hits" |
| Bit rate | bitrate | bitrate:192 |
| Duration | duration | duration:3 |
| 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 |
|---|
| Camera make | cameramake | cameramake:manufacturer |
| Camera model | cameramodel | cameramodel:modelnumber |
| Date taken | datetaken, taken | datetaken:yesterday |
| Dimensions | dimensions | dimensions:8X10 |
| Height | height | height:1200 |
| Orientation | orientation | orientation:landscape |
| Width | width | width:1600 |
Recorded TV
These are properties common to recorded tv. To limit the search to recorded tv only, the syntax is:
kind:tv <property>:<value>
where <property> is a property listed below and <value> is the user-specified search term.
| Property | Use | Example |
|---|
| Broadcast date | broadcastdate | broadcastdate:2005 |
| Channel number | channel | channel:7 |
| Closed captioning | closedcaptioning | closedcaptioning:true |
| Date released | datereleased | datereleased:2005 |
| Episode name | episodename | episodename:sample |
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 |
|---|
| Ext | ext | ext:.avi |
| Name | name, subject | name:"Family Vacation" |
The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, e-mail address, logo, person, places, or events is intended or should be inferred.