You are here: Overviews > Search Requests > Boolean Search Requests > Connectors
Connectors
Close
dtSearch Text Retrieval Engine Programmer's Reference
Connectors

Connectors used in boolean searches

AND Connector

Use the AND connector in a search request to connect two expressions, both of which must be found in any document retrieved. For example: 

apple pie and poached pear would retrieve any document that contained both phrases. 

(apple or banana) and (pear w/5 grape) would retrieve any document that (1) contained either apple OR banana, AND (2) contained pear within 5 words of grape

AndAny Connector

AndAny lets you combine a search for required search terms with other terms that are optional. The words before AndAny are required, and the words after AndAny are optional. Example: 

(apple and pear) AndAny (grape or banana) would find any word that contains apple and pear, and grape and banana will also be counted as hits. 

OR Connector

Use the OR connector in a search request to connect two expressions, at least one of which must be found in any document retrieved. For example, apple pie or poached pear would retrieve any document that contained apple pie, poached pear, or both.

W/N Connector

Use the W/N connector in a search request to specify that one word or phrase must occur within N words of the other. For example, apple w/5 pear would retrieve any document that contained apple within 5 words of pear. The following are examples of search requests using W/N:

(apple or pear) w/5 banana (apple w/5 banana) w/10 pear (apple and banana) w/10 pear

Some types of complex expressions using the W/N connector will produce ambiguous results and should not be used. The following are examples of ambiguous search requests:

(apple and banana) w/10 (pear and grape) (apple w/10 banana) w/10 (pear and grape)

In general, at least one of the two expressions connected by W/N must be a single word or phrase or a group of words and phrases connected by OR. Example:

(apple and banana) w/10 (pear or grape) (apple and banana) w/10 orange tree

dtSearch uses two built in search words to mark the beginning and end of a file: xfirstword and xlastword. The terms are useful if you want to limit a search to the beginning or end of a file. For example, apple w/10 xlastword would search for apple within 10 words of the end of a document.

PRE/N Connector

The pre/N connector is like W/N, but it also requires that the first expression must occur before the second. Example:

(apple or pear) pre/5 banana
NOT and NOT W/N

Use NOT in front of any search expression to reverse its meaning. This allows you to exclude documents from a search. Example:

apple sauce and not pear

NOT standing alone can be the start of a search request. For example, not pear would retrieve all documents that did not contain pear. 

If NOT is not the first connector in a request, you need to use either AND or OR with NOT:

apple or not pear not (apple w/5 pear)

The NOT W/ ("not within") operator allows you to search for a word or phrase not in association with another word or phrase. Example:

apple not w/20 pear

Unlike the W/ operator, NOT W/ is not symmetrical. That is, apple not w/20 pear is not the same as pear not w/20 apple. In the apple not w/20 pear request, dtSearch searches for apple and excludes cases where apple is too close to pear. In the pear not w/20 apple request, dtSearch searches for pear and excludes cases where pear is too close to apple.

CONTAINS Connector and Field Searching

When you index a database or other file containing fields, dtSearch saves the field information so that you can perform searches limited to a particular field. For example, suppose that you indexed an Access database with a Name field and a Description field. You could search for apple in the Name field like this:

Name contains apple

dtSearch automatically collects field information from: databases, META tags in HTML files, XML, and Office and WordPerfect document properties. 

For more information on field searching and metadata, see "Field Searching". 

You can also define a field at the time of a search by designating words that begin and end the field, like this:

(beginning to end) contains (something)

The beginning TO end part defines the boundaries of the field. The CONTAINS part indicates the words or phrases you are searching for in the field. The only connector allowed in the beginning and end expressions in a field definition is OR. Examples:

(name to address) contains john smith (name to (address or xlastword)) contains (oak w/10 lane)

The field boundaries are not considered hits in a search. Only the words being searched for (john smith, oak, lane) are marked as hits.

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