Advanced Search Tutorial

The Advanced Search Builder form is a tool for constructing complex search queries using Boolean logic. The queries so constructed are valid input for both the usual search box and the web API; therefore, this form is provided as a convenience.

Boolean Logic

In Boolean logic, a predicate is an assignment of each of the entities in an underlying domain to one of the values true or false. Predicates are usually written using expressions, or formulas, which are formal strings containing symbols (which may be predicates themselves), along the connectives AND, OR, NOT (respectively conjunction, disjunction, and negation).

Lung AND Cancer
Conjunction: Lung AND Cancer
Lung OR Cancer
Disjunction: Lung OR Cancer
Lung AND NOT Cancer
Negation: Lung AND NOT Cancer
Lung AND Cancer
Conjunction: Lung AND Cancer
Lung OR Cancer
Disjunction: Lung OR Cancer
Lung AND NOT Cancer
Negation: Lung AND NOT Cancer

Often predicates and expressions are identified, but this is not strictly correct because a single Boolean predicate may have many expressions. Two interesting options are conjunctive normal form (CNF) and disjunctive normal form (DNF), which each exist for every Boolean formula, and both are supported by the Advanced Search Builder. In CNF, logical disjunctions are combined using conjunction. In DNF, logical conjunctions are combined using disjunction. Both CNF and DNF allow negations of symbols (or tokens).

Remark: NOT is a unary operator in Boolean logic; that is, it only takes a single argument, so Lung NOT Cancer does not technically make sense (although it is supported). In the Advanced Search Builder, NOT alone means AND NOT: Lung AND NOT Cancer. In particular, the initial term in an expression is not allowed to be negated (because it easily leads to expensive queries). An alternative, OR NOT, is also supported as a separate option whenever NOT is supported; however, OR NOT is confusing in the context of a traditional search engine, and is generally advised against.

Query Groups

Query syntax in DataMed follows the usual convention, where NOT has the highest precedence, followed by AND, and lastly OR. This implies that the order in which tokens are written matters. The operator precedence can be overridden in Boolean logic using parentheses, and such overriding is fully supported in DataMed at any level of depth. However, in the Advanced Search Builder, only one level of parentheses is supported (although the generated expression might have many parentheses, to avoid possible ambiguities). To this end, we introduce the notion of a query group.

Example Query Group

Each query group is separated from all other query groups using parentheses. For example, the usual Boolean convention without parenthetical grouping can only support disjunctive normal form, whereas by using query groups we can choose to use conjunctive normal form instead.

Below all current query groups, a button allows to add a new query group (re-arranging query groups is not supported at the present time).

Add Query Group

If multiple query groups exist, then logical operators (AND, OR, NOT, OR NOT) may be selected between any two query groups, and are evaluated using the usual operator precedence at the topmost level (although, recall, each query group is implicitly contained inside its own set of parentheses). In other words, the usual precedence holds within query groups, and also holds between query groups, but the specific contents of one query group does not formally interact with the specific contents of any other query group.

Page Refresh

Refreshing the page, or clicking through to the search and then clicking the browser Back button, will leave the form state unaltered from its most recent version. Closing the browser tab, or opening a new browser tab or browser window, results in an empty form. Saving form state for later use is not supported at the present time.