Windows Search and its Advanced Query Syntax (AQS) is a freaking awesome feature in Windows. It lets you quickly find a particular file or group of files with a specific name or metadata, in a folder and sub-folders.
Along with indexing file properties or metadata, most known plain-text files are also content indexed by default. When a file type is content indexed, Windows Search lists out the files that contain the word or phrase in the file contents when you type a search phrase in the Search box.
Which Plain-Text Files are “Content Indexed” by Default?
By default, known plain-text file types such as
.VBS. Here is the full list of file types that are, by default, content indexed on a Windows 10 computer:
A, ANS, ASC, ASM, ASX, AU3, BAS, BAT, BCP, C, CC, CLS, CMD, CPP, CS, CSA, CSV, CXX, DBS, DEF, DIC, DOS, DSP, DSW, EXT, FAQ, FKY, H, HPP, HXX, I, IBQ, ICS, IDL, IDQ, INC, INF, INI, INL, INX, JAV, JAVA, JS, KCI, LGN, LST, M3U, MAK, MK, ODH, ODL, PL, PRC, RC2, RC, RCT, REG, RGS, RUL, S, SCC, SOL, SQL, TAB, TDL, TLH, TLI, TRG, TXT, UDF, UDT, USR, VBS, VIW, VSPSCC, VSSCC, VSSSCC, WRI, WTX
Enable Searching File Contents of Any File Type
If you have a custom file type that is of plain-text format, and want to fully index (except the stop words) the contents, you can add the file extension manually in indexing options. Type Indexing Options in the Start/Cortana search box and click on the search result.
To add custom or unknown plain-text files like,
.PHP, in the Indexing Options dialog, click Advanced, and click File Types.
Type the file extension
PHP, select Index Properties and File Contents radio-button, and click OK. After you press OK, the prompt “Rebuilding the index might take a long time to complete. Some views and search results might be incomplete until rebuilding is finished.” appears.
Click OK, and give the indexer considerable time (maybe even hours) to do its job.
Example: Enable Searching File Contents of PowerShell Scripts (.PS1)
PowerShell script file type
.PS1, although it’s a known plain-text file, is not content indexed by default. To demonstrate this, I have two files with different file extensions, but containing exactly the same PowerShell code.
As you can see, the file contains a word named
However, when I typed
defender in the Search text box, it listed only the text (
.txt) file. Although the
.PS1 file has got the same contents, the file wasn’t listed in the search results.
To search file contents of
.PS1 using Windows Search, enable content indexing for the file extension. In Indexing Options, click Advanced, and select the File Types tab. Select
.PS1 from the list and enable Index Properties and File Contents radio-button.
Click OK, and give ample time for Windows Search to index the chosen file type. Rebuilding may take anywhere from minutes to hours depending upon the system configuration, number of files waiting to be indexed, and the user activity level in the system. Don’t expect Windows to content index your additional file types immediately.
After some time, Windows Search indexed the contents of all
.PS1 files duly, and here are the search results:
Exclude Files in Specific Folders to Prevent the Contents Indexed
Content indexing additional file types mean additional database file size and additional resources consumed by the Search Indexer. To keep the database size down, enable the option only for the files you need. For the rest of the file types, you can choose to index only the file properties and metadata.
Besides configuring content indexing on a per-file type basis, you can exclude certain folders (or files) as well. Right-click on a file or folder, click Properties, and click Advanced.
Note: You can do this on a per-file or per-folder basis.
Uncheck Allow files in this folder to have contents indexed in addition to file properties, and click OK. For folders, Windows asks you whether to apply the settings for files from the current folder only, or for sub-folders as well. Choose the appropriate option and click OK.
From now on, Windows Search will not index the contents of the files present in that particular folder, regardless of your per-file type setting in the File Types dialog in Indexing Options. This helps lower the burden of Windows Search, and keeps the database size smaller.
Search file names only, not contents (even with content indexing enabled)
Sometimes, you may want to prevent Windows search from indexing the contents of documents and archives (without turning off the file content indexing feature), restricting the results to filenames only.
To make Windows Search search only for the file name (not contents), use the search operator
For example, the advanced search query
filename:*audit* lists out files that contain the word
audit in the file name, regardless of file contents. For accurate searches, always use advanced search operators.
Refine your searches using Search tab Ribbon commands
Don’t like manually typing or memorizing the advanced query syntax? No problem! use the advanced search ribbon buttons in File Explorer Search tab to refine your searches. It fills up the search operators automatically in the search text box.
For demonstration, I added a 0-byte file named defender.txt along with sample.txt and sample.ps1.
The files sample.txt and sample.ps1 contain the word defender inside the file. In this case, typing defender in the search box lists all three files:
That’s because, for freestyle keyword searches, Windows Search looks for the filename, as well as searches the contents (of included file types) for the keyword used. If I used the Advanced Query Syntax (AQS) syntax
name: it searches for the file name only, as seen in the following screenshot.
filename: operator is always preferred to
name: because the
name: operator will only search from the beginning of the file name, as opposed to anywhere in the file name.
Similarly, there are many such advanced search operators that you’d like to be familiar with. For example, using the AQS, you can search for Files created between two dates. You can mix and match multiple search operators to refine your searches. With Windows Search’s AQS, the opportunities are endless.
Search file contents even in non-indexed locations
Thus far, everything written in this article applies to indexed locations. For non-indexed paths, Windows has to scour through each file or folder in the file system and fetch the results. This will be accurate, but very slow and drains the system resources more.
By default, in non-indexed locations, Windows Search doesn’t search file contents. If you wish to search file contents in non-indexed locations, there is a setting you can enable.
- Open File Explorer, click the File menu, and select “Change folder and search options”.
- Click the Search tab and enable the option named Always search file names and contents (this might take several minutes)
- Click OK.
It’s worth reiterating that the above setting when enabled, will cause the searches to slow down very much, and the system performance certainly takes a hit with constant churning of the hard drive. Please use the above setting judiciously — enable it only when it’s absolutely necessary.
The Windows Search feature, despite the occasional search indexer service hiccups (which can be fixed) which you may experience, is a real time-saver when it works, and it’s a productive tool that eases our workflow.
Information in this article applies to Windows Vista and higher, which includes Windows 10 and Windows Server Operating Systems.
Featured image Credit: earvine95, pixabay.com
One small request: If you liked this post, please share this?One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!