Partager via


Example search box queries

The examples in this topic show you how to find work items using the search boxes in Team Explorer and Team Web Access. You can find items using shortcut filters or by specifying keywords or phrases, specific fields/field values, assignment or date modifications, or using Equals, Contains, and Not operators.

Search box queries automatically scope to the items defined to the team project you’re currently connected to. To search across team projects, use the query editor. Also, searching is not case-sensitive.

Use shortcut filters

Open the Context Menu Icon context menu and select an option.



Context menu for search box (Team Web Access)

Search box shortcut menu (Team Web Access)


Context menu for search box (Team Explorer)

Search box menu (Team Explorer)

You can enter or select one or more of the following shortcut identifiers:

  • A =for Assigned To, (for example, A:Annie or A=@me).

  • C for = Created By, (for example, C:Peter or C=@me).

  • S for = State, (for example, S=New).

  • T for = Work Item Type, (for example, T=Task).

Use the @Me and @Today macros to specify your user name or today’s date.

Use the =, :, and – operators to specify the operations Equals, Contains, and Not, respectively.

Finding work items using the search box (Team Explorer)

Find a work item using the search text box

You can combine shortcuts and use search operators within the search box.

In Team Explorer, use the Search box clear icon (Team Explorer)Clear button to remove content from the search box. To switch your context to the search box from within Visual Studio, enter Ctrl+'.

Find items based on keywords or phrases

Keywords or phrases that you type into the search box return a list of work items that contain those keywords or phrases in the Description, Repro Steps, or Title fields. You must enclose each phrase in quotation marks.

In the Search work items box, type a keyword or phrase that appears in the Title, Description, or Repro Steps fields for the work items of interest.

Enclose multiple words in quotation marks.

For example, to find work items with the specified keywords in the Title or Description fields:

  • For the keyword "duplication" enter duplication.

  • For the phrase "Getting Started" enter "Getting Started".

  • For the phrase "Getting Started" or the keyword "feature" enter feature "Getting Started".

To find all work items that contain the following keywords or phrases:

Type the following string into the search box:

duplication

duplication

Getting Started

"Getting Started"

feature and Getting Started

feature "Getting Started"

You can perform partial or exact match queries on a keyword or a phrase contained within any text field. Or, you can perform a full-text search query by filtering on keywords and phrases contained within the full-text search index. Team Foundation automatically indexes all long-text fields with a data type of PlainText and HTML and the Title field for full-text search.

Find items based on specific fields and field values

To find work items based on a keyword or phrase contained within other text string fields, specify either the friendly name or the reference name of the field. Enclose each phrase in quotation marks. You can determine the friendly name of a field by hovering over the field within a work item form. To determine the reference name of commonly used fields or to find a field that is not listed on the form, see Work item field reference for Visual Studio ALM.

To find items that meet the following criteria:

Type the following string:

Contains one attached file.

System.AttachedFileCount=1

Cut user stories.

T:Story Reason=Cut

Or

T="User Story" System.Reason=Cut

Resolved by Peter.

"Resolved By":Peter

Or

Microsoft.VSTS.Common.ResolvedBy:Peter

Modified today.

"Changed Date"=@Today

Created yesterday as a test activity.

"Created Date"=@Today-1 Activity=Test

Note

Some fields, such as History and Description, do not support partial word text searches. For example, if the History field contains the phrase reproducible behavior and you search for History:repro the work item will not be found. However, if you search for the complete string History:reproducible the work item will be found.

Find items based on assignment or date modifications using @Me or @Today macros

The @Me macro expands to the full name of the current user in any work item search. The @Me macro is especially useful for creating a search that you can share with other users, and it can simplify your work by reducing the number of characters you must type to specify your own user name.

To find items that meet the following criteria:

Type the following string:

Currently assigned to you.

A=@Me

Created by you.

C=@Me

Resolved yesterday.

"Resolved Date"=@Today-1

Modified 7 days ago.

System.ChangedDate=@Today-7

Created yesterday under the Phone Saver team for the FabrikamFiber team project.

"Created Date"=@Today-1 "Area Path"="FabrikamFiber\Phone Saver"

Use the Equals, Contains, and Not operators to refine your query

Use these search operators to specify search criteria:

  • = (EQUALS) to search for exact matches of text.

  • : (CONTAINS) to search for partial matches of text.

  • (NOT) to exclude work items that contain certain text. The NOT operator can only be used with field names.

The following examples show how to use operators when you create a search string.

To find items that meet the following criteria:

Type the following string:

Assigned to Peter and not Active.

A:Peter -S=Active

In which the Activity field was not Development.

- Activity=Development

Resolved by Peter.

"Resolved By":Peter

Contain the keyword triage in the title or description, are not assigned to you, and are not closed.

triage -A=@me -S=Closed

Active bugs that are assigned to you that do not contain the keyword bugbash in the title.

S=Active T=bug A=@Me -Title:bugbash

Q & A

Q: Can I use a comparison operator?

A: No. The search box doesn’t recognize comparison operators such as greater than (>) or less than (<). It translates queries with these operators into a search phrase.