Query Parser Syntax

Overview

The 337Info Advanced Search - Query Builder provides the ability to create your own queries using a rich query language, the syntax of which is described below. Many of the functions described below can be applied to the general text search function on the 337Info Homepage as well as on the Query Builder page. Maintaining the proper syntax sent to the search engine behind the query builder is necesssary to avoid receiving an error message. Specific examples of how to apply the query language are also provided in the 337Info FAQ document.

Terms

A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.

A Single Term is a single word such as "test" or "hello".

A Phrase is a group of words surrounded by double quotes such as "hello dolly".

Multiple terms can be combined together with Boolean operators to form a more complex query (see below).

Fields

The query builder allows you to search against the fields that contain the information in the 337Info database. The query builder allows you to select the field you want to query on and it will translate that for you into the technical name used to query the database.The query builder does not allow you to specify the field names directly.

Your search query will be built by translating the name of the field you select into the database field name followed by a colon ":" and then the term you are looking for. The translated query will be shown at the top of the search results page.

As an example, if you wanted to search all investigation titles containing the word "wireless" your field query will be constructed as:

title:"wireless"

You can augment field terms in your search by adding additional terms to search on as general text. As an example, if you wanted to search all investigation titles containing the word “wireless” presided over by Judge Gildea, your field query could be constructed as:

title:"wireless" AND Gildea

The field is only valid for the term that it directly precedes (unless using field grouping, described below), so this query

Will only look for "Wireless" in the title field, but it will search for "Gildea" across all fields in the database.

Term Modifiers

The search engine behind the Advanced Search - Query Builder supports modifying query terms to provide a wide range of searching options.

Wildcard Searches

The search engine supports single and multiple character wildcard searches within single terms (not within phrase queries).

To perform a single character wildcard search use the "?" symbol.

To perform a multiple character wildcard search use the "*" symbol.

The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "text" or "test" you can use the search:

te?t

Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or tester, you can use the search:

test*

You can also use the wildcard searches in the middle of a term.

te*t

Note: You cannot use a * or ? symbol as the first character of a search.

Fuzzy Searches

The search engine supports fuzzy searches meaning you can instruct it to search for words which are spelled similarly to the term you provide. To do a fuzzy search use the tilde, "~", symbol at the end of a Single word Term. For example to search for a term similar in spelling to "roam" use the fuzzy search:

roam~

This search will find terms like foam and roams. This capability is especially useful if you do not know the exact way to spell a term.

Proximity Searches

The search engine supports finding words within a specific distance away from each other. To do a proximity search use the tilde, "~", symbol at the end of a phrase. For example to search for "dental" and "appliances" within 10 words of each other use the search:

"dental appliances"~10

Range Searches

Range Queries allow one to match documents whose field(s) values are between the lower and upper bound specified by the Range Query. Range Queries can be inclusive or exclusive of the upper and lower bounds. Sorting is done lexicographically.

investigationNo:[500 TO 1600]

This will find investigations whose investigation No. field has values between 500 and 1600, inclusive. Note that Range Queries are not reserved for date fields. You could also use range queries with date fields.

Inclusive range queries are denoted by square brackets. Exclusive range queries are denoted by curly brackets.

Boolean Operators

Boolean operators allow terms to be combined through logic operators. Lucene supports OR, AND, "+", NOT and "-" as Boolean operators(Note: Boolean operators must be ALL CAPS).

The OR operator is the default conjunction operator. This means that if there is no Boolean operator between two terms, the OR operator is used. The OR operator links two terms and finds a matching document if either of the terms exist in a document. This is equivalent to a union using sets. The symbol || can be used in place of the word OR.

To search for documents that contain either "mobile phones" or just "mobile devices" use the query:

"mobile phones" "mobile devices"

or

"mobile phones" OR "mobile devices"

AND

The AND operator matches documents where both terms exist anywhere in the text of a single document. This is equivalent to an intersection using sets. The symbol && can be used in place of the word AND.

To search for documents that contain "electronic devices" and "phones" use the query:

"electronic devices" AND "phones"

+

The "+" or required operator requires that the term after the "+" symbol exist somewhere in a field of a single document.

To search for documents that must contain "phones" and may contain "electronic" use the query:

+phones electronic

NOT

The NOT operator excludes documents that contain the term after NOT. This is equivalent to a difference using sets. The symbol ! can be used in place of the word NOT.

To search for documents that contain "electronic devices" but not "mobile" or "wireless" or "portable" use the query:

"electronic devices" NOT (mobile wireless portable)

Note: The NOT operator cannot be used with just one term. For example, the following search will return no results:

NOT mobile

-

The "-" or prohibit operator excludes records that contain the term after the "-" symbol.

To search for record that do not contain "mobile" or "wireless" but not "portable" use the query:

-(mobile portable) portable

Grouping

The search engine supports using parentheses to group clauses to form sub queries. This can be very useful if you want to control the boolean logic for a query.

To search for either "mobile" or "portable" but excluding "wireless" use the query:

(mobile OR portable) AND !wireless

Field Grouping

The search engine supports using parentheses to group multiple clauses to a single field.

To search for a title that must contain the word "mobile" and the phrase "electronic devices" use the query:

title:(+mobile +"electronic devices")

Escaping Special Characters

The search engine supports escaping special characters that are part of the query syntax. The current list special characters are

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \

To escape these character use the \ before the character. For example to search for (1+1):2 use the query:

\(1\+1\)\:2