Managing the SP Gatherer's temp files

While the SharePoint Gatherer is processing files (Office documents, PDFs, etc), it will store them temporarily on local disk.  By default this is in the Temp folder of the user running the OSearch14 service.  It'll look something like:

C:\Users\SHAREP~1\AppData\Local\Temp\gthrsvc_OSearch14

And during a large crawl, this directory can at times get quite large.  (as I found out today when a dev server started complaining abou the C drive being full)

Moving it is easy enough and there are 2 ways.

First, update the service application:

$searchapp= Get-SPEnterpriseSearchServiceApplication -identity "FAST Content SSA"
$searchapp.TempPath = "D:\SearchTemp"

Note that setting the path takes effect immediately.  No need to call the $searchapp.Update() method.

UPDATE 5/17/2013
If you use the SSA.TempPath approach and have multiple crawlers, you need to make sure to run the command on each server anyway.

Second approach is to update the registry directly:

$gmpath = 'HKLM:\Software\Microsoft\Office Server\14.0\Search\Global\Gathering Manager'
Set-ItemProperty -Path $gmpath -Name UseSystemTemp -Value 0
Set-ItemProperty -Path $gmpath -Name TempPath -Value "D:\SearchTemp"
Restart-Service OSearch14

And don't forget to exclude the new temp folder from any AV scans.

(Thanks Sreedhar)

Reference

https://technet.microsoft.com/en-us/library/ee513078.aspx