dtSearch Text Retrieval Engine Programmer's Reference
Field Searching

Search fields in databases and document properties associated with files

Boolean searches

To limit a search request to a particular field in a document, use the following syntax:

FieldName contains ( search request )


City contains (portland or Seattle)


Field searches can be combined using boolean operators, like this:

(City contains (portland or Seattle)) and (Address contains (Washington))

The parenthesis are necessary to ensure that dtSearch interprets the search request correctly.

Alternative field searching syntax

An alternative syntax for field searches is to add the field name and :: in front of each word, like this:

(City::Portland or City::Seattle) and (Address::Washington)

The alternative syntax can be used where the boolean syntax is not possible, such as in "all words" or "any words" searches and file conditions.

Nesting field criteria

Some file formats such as XML support nesting of fields. Example:

<record> <name>John Smith</name> <address> <street>123 Oak Street</street> <city>Middleton</city> ...


In dtSearch, a search of a field includes any fields that are nested inside of the field, so the XML file above would be retrieved in a search for any of the following:

record contains oak address contains oak street contains oak


To specify a specific subfield of a field, use / to separate the field names, like this:

record/address contains oak address/street contains oak record/address/street contains oak


Put a / at the front of the field name to specify that it cannot be a sub-field of another field:

/record/name contains Smith /name contains Smith

The second search request above would not match the XML example because, while it contains a "name" field, the name field is a sub-field of the record-field. A search for /name specifies a "name" field at the top of the field hierarchy. 


Use // to specify any number of unspecified intervening fields, like this:

/record//city contains Middleton


Specifying that text is not in a field

To search for text that is not in any field, search for //text contains (search request). The //text field name means "not in any field".

Punctuation in Field Names

dtSearch removes punctuation from field names when indexing, with these exceptions: :&_+=. 

Spaces are also removed. The hyphen is mapped to an underscore. 

When searching, only searchable letters in field names are treated as significant.