You are here: Overviews > Search Settings > Limiting Searches
Close
dtSearch Text Retrieval Engine Programmer's Reference
Limiting Searches

AutoStopLimit, MaxFilesToRetrieve, and TimeoutSeconds search settings.

MaxFilesToRetrieve
API to use MaxFilesToRetrieve
C/C++
Set dtsSearchJob.maxFilesToRetrieve, and use a dtsSearchResults object to obtain search results.
C++ Support Classes
Call DSearchJob.SetMaxFiles()
.NET (C#,VB.NET)
Set SearchJob.MaxFilesToRetrieve
Java
Call SearchJob.setMaxFilesToRetrieve()
COM (Visual Basic, ASP)
Set SearchJob.MaxFilesToRetrieve

The MaxFilesToRetrieve value limits the number of items returned in search results to the best-matching documents. The search is fully executed, so the search job will return the correct value for the total number of files retrieved. For example, if you do a search with a MaxFilesToRetrieveValue of 100 and the search finds 1400 documents, the search results object will contain 100 items (the best-matching 100 files found in the search) and the search job will indicate that a total of 1400 documents were found. 

The "best matching" documents are selected on the basis of relevance. 

MaxFilesToRetrieve can be used in combination with the dtsSearchDelayDocInfo flag to greatly improve search performance for long searches.

TimeoutSeconds and AutoStopLimit
API to use Timeout Seconds
C/C++
Set dtsSearchJob.timeoutSeconds
C++ Support Classes
Call DSearchJob.SetTimeoutSeconds()
.NET (C#,VB.NET)
Set SearchJob.TimeoutSeconds
Java
Call SearchJob.setTimeoutSeconds()
COM (Visual Basic, ASP)
Set SearchJob.TimeoutSeconds

 

 

API to use AutoStopLimit
C/C++
Set dtsSearchJob.autoStopLimit
C++ Support Classes
Call DSearchJob's SetAutoStopLimit()
.NET (C#,VB.NET)
Set SearchJob.AutoStopLimit
Java
Call SearchJob.setAutoStopLimit()
COM (Visual Basic, ASP)
Set SearchJob.AutoStopLimit

 

Using the MaxFilesToRetrieve value and the dtsSearchDelayDocInfo flag, the amount of time required for each item retrieved in a search can be reduced quite a bit, but search time will still be roughly proportional to the number of documents retrieved. While a search that finds 1000 documents will still be very fast, a search that retrieves a sufficiently large number of documents can still take a long time. 

To prevent searches that find hundreds of thousands or millions of documents from consuming an excessive amount of resources on a server, you can use two limits on a search job that will halt the search unconditionally. 

First, you can use TimeoutSeconds to halt a search that takes more than a certain number of seconds. For example, if you set TimeoutSeconds = 5, a search will always halt after five seconds. 

Second, you can use the AutoStopLimit to halt a search after a specified number of documents have been retrieved. For example, if you set AutoStopLimit to 1000, the search will automatically halt after 1000 documents have been found. 

AutoStopLimit vs MaxFilesToRetrieve 

AutoStopLimit tells dtSearch to stop searching after a certain number of files have been found, while MaxFilesToRetrieve tells dtSearch how many files to return in search results. For example, if AutoStopLimit is 500 and MaxFilesToRetrieve is 100, then the search will return the best-matching 100 files out of the first 500 retrieved. 

How to tell if a limit was reached 

The error handler for a search job will tell you if the search job was terminated because of one of these limits. If the TimeoutSeconds value was reached, it will contain dtsErTimeout (13). If the AutoStopLimit was reached, it will contains dtsErSearchLimitReached (120). 

If AutoStopLimit is zero (the default value), the search will continue until all matching documents are found.

Copyright (c) 1995-2021 dtSearch Corp. All rights reserved.