# Query DSL

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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.invariant.io/content-insight/query-dsl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
