# Package org.crosswire.jsword.index.query

The Query package provides JSword with the ability to construct a search request against an Index.

See: Description

- Interface Summary
  Interface | Description
  --- | ---
  BinaryQuery | A BinaryQuery consists of a Left and a Right Query
  Query | The search.Searcher uses a Query to calculate a search result.
  QueryBuilder | A QueryBuilder builds a Query from a String.
  QueryDecorator | A QueryDecorator allows for the decoration of strings in a way that is appropriate for a Query.

- Class Summary
  Class | Description
  --- | ---
  AbstractBinaryQuery | A binary query has a left query and right query.
  AbstractQuery | A base query is the smallest unit of search that the index can perform.
  AndNotQuery | An "And Not" query specifies that a result needs to be in the left but not in the right query result.
  AndQuery | An AND query specifies that a result needs to be in both the left and the right query results.
  BaseQuery | A base query is the smallest unit of search that the index can perform.
  BlurQuery | A blur query specifies how much to blur the results of the right query before ANDing it to the left.
  NullQuery | A null query searches for nothing and returns an empty Key.
  OrQuery | An OR query specifies that a result is the union of the left and the right query results.
  QueryBuilderFactory | A Factory class for QueryBuilder.
  QueryDecoratorFactory | A Factory class for QueryDecorator.
  RangeQuery | A range query specifies how a range should be included in the search.

## Package org.crosswire.jsword.index.query Description

The Query package provides JSword with the ability to construct a search request against an Index. The specific syntax of a query is an implementation detail.

## Query

The search request consists of one of the following:

- `Query`: search for a single atom, or
- `BinaryQuery`: search consisting of a left query and a right query joined by an operator, or
- `NullQuery`: search for nothing, returning nothing.

Note: an atom is the smallest unit of search that can be handled directly by the index.

The typical binary operators are:

- `AndQuery`: All that is common between the left and the right.
- `OrQuery`: All that is in both the left and the right.
- `AndNotQuery`: All that is in the left minus what is in the right.

The uncommon binary operators are:

- `RangeQuery`: There are two types of ranges: within a and without.
  - Within: All the results that are within a Range of Keys.
  - Without: All the results that are outside a Range of Keys.
- `BlurQuery`: Like an AndQuery except that the right query is first blurred by a requested amount.

## Query Parsing

The `QueryBuilder` takes a search request as a string and generates a Query from it. The primary characteristic of the Query builder is to determine the atoms of search and construct a Query appropriately.

## Query Decorations

Beyond the above queries, most modern query languages allow for specialized searching using notation that is peculiar to it. The `QueryDecorator` allows for phrases to be decorated in a way that is appropriate for the Index. The following are the decorations that are currently defined:

- Phrase decoration - find the phrase.
- Spelling decoration - find words that sound like or are similar to the one that is given
- Start With decoration - find words that start with the given words.
- All Words decoration - an AndQuery decorator
- Any Words decoration - an OrQuery decorator
- Not Words decoration - an AndNotQuery decorator
- Range decoration - decorates an AND range