Close
dtSearch Text Retrieval Engine Programmer's Reference
Retrieving Fields in Search Results

How to use "stored" fields to store document meta-data in the index and obtain it in search results.

All fields in documents are automatically searchable once you have indexed the documents. There is no limit on the amount of field data that dtSearch can search in each file, and no limit on the size of each field. 

In some situations it is useful not only to be able to search for the contents of fields, but to have the contents of one or more fields returned along with other document properties in search results. dtSearch can return fields in search results if they are designated when the document is indexed as "stored" fields.

Storing Fields

dtSearch Desktop Click Index > Create Index (Advanced) in dtSearch Desktop, and list the fields to store under Fields to display in search results 

dtSearch Engine Set IndexJob.StoredFields to a list of field names. The field names in the list can contain wildcards (* and ?). A set containing a single entry "*" would match all fields, causing the text of every field to be stored in the index. 

Hidden Stored Fields 

A hidden stored field is like a stored field, except that the text is not searchable. Hidden stored fields provide a way to store document properties in the index without making those properties searchable. 

Hidden stored fields can only be created in the data source API, using dtsInputStream.fields or the DocFields member of a DataSource object. To designate a field as a hidden stored field, add ** in front of the field name, like this: 

"**HiddenStoredField"

Limits on Stored Fields

By default, the maximum size of a stored field is 128 characters. This can be changed with the maxStoredFieldSize option setting, and can be increased to up to 8192 characters. The total size of all all stored fields associated with a single document, including field names, is limited to 27k. 

These limits do not affect field searching. All fields in a document are searchable, regardless of how long they are or how many fields are in the document. For example, in a document with 100 fields, each 64k in length, all of the data in all of the fields would be searchable. The limits described here apply only to fields that are copied into the index and returned in search results.

Language/Environment
API to specify the limit on stored fields
dtSearch Desktop
HKEY_CURRENT_USER\Software\dtSearch Corp.\dtSearch\Settings\MaxStoredFieldSize
C/C++
Set dtsOptions.maxStoredFieldSize
C++ Support Classes
Set Set DOptions.maxStoredFieldSize
.NET (C#, VB.NET)
Set Options.MaxStoredFieldSize
Java
Call Options.setMaxStoredFieldSize
COM (Visual Basic, ASP)
Set Options.MaxStoredFieldSize
Obtaining Stored Fields

dtSearch After a search, dtSearch displays any stored field data returned as additional columns in search results. For example, if you create a "Subject" stored field, the search results list will contain a "Subject" column after the other columns. 

dtSearch Web In dtSearch Web, the Build Search Form dialog box has a Search Results tab that lets you specify the items to include in search results. To add a custom field, click the Add button and add an item with the name of the field you want. Under Content, use %% around the name of a field to get the value of that field. For example, to add the "Subject" field to search results, you would create a new item in Search Results named "Subject", and under Content you would enter 

%%Subject%%  

Language/Environment
API to obtain stored field values
dtSearch Desktop
Stored fields will appear as columns in search results
C/C++
dtsSearchResults.userFields (a null-delimited list of field names and values).
C++ Support Classes
DSearchResults.GetDocInfoItem("FieldName")
.NET (C#, VB.NET)
SearchResultsItem.UserFields["FieldName"]
Java
SearchResults.getDocDetailItem("FieldName")
COM (Visual Basic, ASP)
SearchResults.DocDetailItem("FieldName)"