Share via


Example Queries

Note

Indexing Service is no longer supported as of Windows XP and is unavailable for use as of Windows 8. Instead, use Windows Search for client side search and Microsoft Search Server Express for server side search.

 

The following table illustrates several example queries. The examples for the short form of Dialect 2 generally apply to Dialect 1 with the exception of the incompatibilities noted in Incompatibilities of Dialect 2 with Dialect 1.

Example Version Results
{prop name=Contents} apple tree {/prop} Dialect 2 Documents with the phrase apple tree.
{phrase} apple tree {/phrase} Dialect 2 Documents with the phrase apple tree.
"apple tree" Dialect 2, short form Documents with the phrase apple tree.
apple tree Dialect 2, short form Documents with either or both of the words apple and tree.
apple tree Dialect 1 Documents with the phrase apple tree.
apple {near dist=50, unit=word} tree Dialect 2 Documents with the words apple and tree within 50 words of each other.
Microsoft near release and {prop name=rank} > 0 Dialect 2 Documents containing the words Microsoft and release occurring near each other.
Microsoft ~ release & @rank > 0 Dialect 2, short form, or Dialect 1 Documents containing the words Microsoft and release occurring near each other.
$contents Why is the sky blue? Dialect 2, short form, or Dialect 1 Documents that match the free-text query (which are about the blue sky).
@size > 1000000 & < 2000000 Dialect 2, short form, or Dialect 1 Documents larger than 1 million bytes but smaller than 2 million bytes.
{prop name=size} > 1000000 & < 2000000 Dialect 2 Documents larger than 1 million bytes but smaller than 2 million bytes.
@attrib ^s 32 Dialect 2, short form, or Dialect 1 Documents with the archive attribute bit on.
@all Excel & ( @size > 1000 & < 100000 ) & Microsoft Dialect 2, short form, or Dialect 1 Documents containing the words Excel and Microsoft that are between 1,000 and 100,000 bytes in size.
{prop name=all} Excel and {prop name=size} > 1000 and < 100000 ) {/prop} and Microsoft Dialect 2 Documents containing the words Excel and Microsoft that are between 1,000 and 100,000 bytes in size.
@Write > -2d Dialect 2, short form, or Dialect 1 All documents changed within the last two days.
@Write > 2000-1-1 Dialect 2, short form, or Dialect 1 All documents on or after the year 2000.
@filename = *.avi Dialect 2, short form, or Dialect 1 Video files. The = indicates the query contains an MS-DOS/Windows wildcard character.
#filename *.avi Dialect 2, short form, or Dialect 1 Video files. The # prefix indicates the query contains a regular expression.
#filename *.|(do?|,xl?|,p?t|,mdb|) Dialect 2, short form, or Dialect 1 Microsoft Office documents.
{prop name=filename} {regex}*.|(do?|,xl?|,p?t|,mdb|){/regex} Dialect 2 Microsoft Office documents.
#path "*\|[^\]|[14,|}\*" Dialect 2, short form, or Dialect 1 Paths with a directory component containing fourteen or more characters.
{prop name=path}{regex}"*\|[^\]|[14,|}\*"{/regex} Dialect 2 Paths with a directory component containing fourteen or more characters.
{generate method=prefix} dog {/generate} Dialect 2 All words beginning with dog: For example, dog, dogs, doghouse, dogma.
@contents BackOffice &! #vpath *\_vti_* Dialect 2, short form, or Dialect 1 Documents containing the word BackOffice, but which are not in Microsoft FrontPage hidden directories. Microsoft BackOffice is a family of server software, designed to integrate various computer functions for businesses.
{prop name=contents} BackOffice AND NOT {prop name=vpath}{regex}*\_vti_*{/regex} Dialect 2 Documents containing the word BackOffice, but which are not in Microsoft FrontPage hidden directories.
SELECT * FROM FILEINFO
  WHERE size > 1000000
SQL Documents larger than 1 million bytes.
SELECT FileName FROM SCOPE()
  WHERE CONTAINS ('search')
    AND NOT CONTAINS ('slow')
SQL Documents with the phrase search but not the phrase slow.
SELECT DocAuthor, DocTitle
FROM SCOPE()
  WHERE CONTAINS(DocAuthor,
         'smith')
SQL Documents written by Smith.
...WHERE CONTAINS(DocSubject,
         '"Microsoft" 
          AND "Indexing" 
          NEAR "Service"')
SQL Documents containing the words Microsoft and Indexing near the word Service.