Faceted Search

Last Reviewed: March 4, 2012

Article: DTS0222

 

Applies to: dtSearch Engine 7.60 and later

The dtSearch Engine's WordListBuilder object can be used to quickly enumerate document properties for documents retrieved in a search.  This feature can be used to implement a faceted search interface, in which search results summarize values and document counts for one or more categories of document metadata after a search.  

Indexing

When documents are indexed, set IndexJob.EnumerableFields to a comma-separated list of field names.  EnumerableFields are fields whose values will be stored in the index in a way that permits fast enumeration. All EnumerableFields are also StoredFields.  The EnumerableFields setting has no effect on document retrieval.

Searching

(1) In SearchJob, set WantResultsAsFilter=true so a SearchFilter will be returned along with the SearchResults. The SearchFilter will be a bit vector identifying all of the documents that match the search request.  (If you are executing a search specifically to create a SearchFilter and do not need SearchResults from the search, set the flag dtsSearchFastSearchFilterOnly in SearchJob to improve search speed.)

(2) To enumerate the values of a field for all documents retrieved in the search, create a WordListBuilder object and set it up as follows

- Set IndexPath to the index that was searched.

- Call WordListBuilder.SetFilter() to limit the values returned to the documents that were returned from the search.

- Call WordListBuilder.ListFieldValues() with the field name to enumerate.

A sample application demonstrating EnumerableFields is installed here:

C:\Program Files\dtSearch Developer\examples\cs2\ListFields

To use the sample,

(1) Build an index of some faceted data with one or more fields listed in EnumerableFields (enter * under EnumerableFields to make all fields enumerable)

(2) Use the Search and Browse Fields dialogs to search and browse field values within the results of a search.

For API documentation, see WordListBuilder.ListFieldValues and IndexJob.EnumerableFields in C:\Program Files\dtSearch Developer\help\dtSearchNetApi2.chm

Click here for information on a faceted search dtSearch Engine add-on developed by Contegra Systems.

For a developer tutorial on implementing a faceted search user interface, please see these two articles at CodeProject.com:
Faceted search (1)   

Faceted search (2)