dtSearch Text Retrieval Engine Programmer's Reference
Limiting searches with SearchFilters

The SearchFilter object can be used to limit searches to a complex subset of a document collection, with minimal search-time overhead.

The dtSearch Engine's developer API has a SearchFilter object that can be used to implement complex search restrictions, such as access rights stored in a database that specify the users who can access each document. A SearchFilter object specifies, for one or more indexes, which documents can be returned in a search. SearchFilter objects can be constructed from query results or directly from document ids, and can be saved to disk and read from disk. 

SearchFilters can be useful in a variety of situations where a full-text query must be combined with a different type of search restriction, such as a database search, a geographical criterion, or a set of security restrictions. 

SearchFilters are implemented in a way that adds close to zero additional search time when they are used to limit a search. As a result, they can greatly improve performance over other approaches that express the equivalent restriction as a search request.

Document Ids

Search filters do not use names to identify documents because a filter may specify thousands, or hundreds of thousands, of documents, and a table of filenames would take too much memory and would take too long to check. Instead, each document is identified by (a) the index it belongs to, and (b) the document's document id or "DocId", a unique integer that is assigned to each document in an index. The DocId for a document can be obtained by searching for the document by name, and then examining the document's properties in search results. It can also be obtained during indexing by using the DataSource abstract class as the base for your data source implementation. 

A DocId that is selected may be returned in search results. A document that is not selected will not be returned in search results, even if it otherwise satisfies the search request. 

A search filter is implemented in the dtSearch Engine using a table of bit vectors, one for each index in the filter. Each bit vector has one bit for each document in its index. For example, a search filter for a single index with 1,000,000 documents would have 1,000,000 bits, or 125 kilobytes of data.

COM (Visual Basic, ASP)
ISearchFilter (SearchFilter)