> For the complete documentation index, see [llms.txt](https://docs.invariant.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.invariant.io/content-insight/query-dsl.md).

# Query DSL

Domain Specific Language for document search

Invariant Content Insight uses Elasticsearch engine for storage and the content search module makes use of Elasticsearch [Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html)

The query string (search\_text parameter) passed to the engine is parsed into a series of terms and operators. A term can be a single word — tasty or chicken — or a phrase, surrounded by double quotes — "tasty chicken" — which searches for all the words in the phrase, in the same order.

The search can be customized using operators listed below.

#### Wildcards

Wildcard searches can be run on individual terms, using `?` to replace a single character, and `*` to replace zero or more characters. Wildcard searches are not efficient and their use should be limited.

#### Boolean operators <a href="#boolean_operators" id="boolean_operators"></a>

By default, all terms are optional, as long as one term matches. A search for `fish frog turtle` will find any document that contains one or more of `fish` or `frog` or `turtle`. There are also boolean operators which can be used in the query string itself to provide more control.

The preferred operators are `+` (this term **must** be present) and `-` (this term **must not** be present). All other terms are optional.

For example, in the following query:

```
wise fishes +monkey -tortoise
·       monkey must be present
·       tortoise must not be present
·       wise and fishes are optional — their presence increases the search relevance

```

The familiar operators `AND`, `OR` and `NOT` (also written `&&`, `||` and `!`) are also supported. However, you have to keep the precedence in mind when using these. `NOT` takes precedence over `AND`, which takes precedence over `OR`.

The operators `+` and `-` only affect the term to the right of the operator. `AND` and `OR` operators can affect the terms to the left and right.

#### Grouping <a href="#grouping" id="grouping"></a>

Multiple terms or clauses can be grouped together with parentheses to form sub-queries:

```
(smart OR hungry) AND bears
```
