# Ask questions with Query Language

The Query Language is an intuitive way to build complex multi-omic queries without having to memorize your entire graph schema. &#x20;

To begin writing in Query Language, ensure that the search is toggled to "Query Language".&#x20;

<figure><img src="/files/gGwF86yNKMVpQC4uWXxv" alt=""><figcaption></figcaption></figure>

\
A query is made up of **concepts** and **relationships**. A **concept** is surrounded by parentheses `()`, for example, to match against the concept `Gene` use `(Gene)`.\
\
While using the Query Language, a look-ahead menu shows possible outbound and inbound relationships from a starting concept. Each data graph on the BioBox platform is unique. This means all options that you see in this menu are tailored to the relationships and concepts uniquely found in your custom graph.&#x20;

## How to Construct a Query

\
In this example we will walk through the building a query that will identify genes upregulated in differential expression datasets where the experimental group was diagnosed with endometrium adenocarcinoma. \
\
This natural language question translates to the query

{% code overflow="wrap" %}

```
(Gene)<- upregulates <-(DifferentialExpressionDataset)-> experimental group includes ->(TumorSample)-> pathologically confirmed to be ->(Disease{displayName="endometrium adenocarcinoma"})
```

{% endcode %}

\
To start writing the query, type "Gene". This will activate the lookahead menu, which shows available outbound and inbound relationships. The lookahead displays the relationship, its directionality, and the associated concept.&#x20;

Starting with "Gene" some of the relationship-concept combinations in this example graph include&#x20;

<figure><img src="/files/jJ18HDM2Y1xXqxwf4NX3" alt=""><figcaption></figcaption></figure>

You can scroll through the menu or continue typing until you find the relationship you are looking for.&#x20;

The relationship and concept can be selected from the menu or you can type it out manually. **The spelling and case must be exact.**<br>

These queries can also be constructed using [natural language.](/guide/how-to/ask-multi-modal-questions/ask-questions-with-natural-language-graphrag.md)&#x20;

## Adding Data Properties

Concepts and relationships can be further filtered using **data property filters**. When writing a query, all of the data properties associated with a concept or relationship can be used to further refine the data that will be returned.

Within a concept, **data property filters** can be included following the concept label within brace brackets `{}`. Data property filters have the format `[key][op][value]` where `key` is the name of the property and `op` is any of

* `=~`
* `<=`
* `>=`
* `!=`
* `=`
* `>`
* `<`

For numeric properties, the filter value is a number, for example `{ a=1 }`. For string properties, the value must be wrapped in quotations, for example `{ uuid="x" }`. For boolean properties, the filter value is either of `true` or `false`, for example `{ x=false }`.

Data filter properties are separated by the logical operators `&` (and) and `|` (or). For example, a complete concept and filter: `(Gene { start>1000 & strand=1 })`. This example is also valid on its own as a query may only specify one concept.

A **relationship** is specified by connecting concepts with the format `<-[label]<-`, `->[label]->`, or `-[label]-` For example, `-> participates in ->`. The autocomplete will assume arrows format.

**Putting this all together, a complete minimal example is:**

{% code overflow="wrap" %}

```
(Gene { start>1000 & strand=1 })-> participates in ->(Pathway)
```

{% endcode %}

Statements can also specify a `NOT` path filter at the end of the statement. This is a path based filter and must include at least one variable and at least one relationship.

A valid `NOT` filter is:

{% code overflow="wrap" %}

```
(s:Sample)-> pathologically confirmed to be ->(Disease) NOT (s:Sample)-> has variant ->(FivePrimeUTR)
```

{% endcode %}

The following query is invalid because there are no variables used in the `NOT` filter:

{% code overflow="wrap" %}

```
(s:Sample)-> pathologically confirmed to be ->(Disease) NOT (Sample)-> has variant ->(FivePrimeUTR)
```

{% endcode %}

The following query is invalid because the `NOT` filter only specifies a single concept and not a complete relationship:

{% code overflow="wrap" %}

```
(s:Sample)-> pathologically confirmed to be ->(Disease) NOT (s:Sample)
```

{% endcode %}

A statement is a relationship plus optionally a `NOT` filter. Multiple statements can be combined using `+`, and at least one variable must be chained through per statement:

{% code overflow="wrap" %}

```
(Sample)-> expresses ->(g:Gene)-> participates in ->(Pathway { displayName="Deubiquitination
```

{% endcode %}

Once you have launched your query it is time to explore your results. Learn more about exploring and [understanding your results here. ](/guide/how-to/ask-multi-modal-questions/ask-questions-with-query-language/explore-and-understand-your-results.md)


---

# 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.biobox.io/guide/how-to/ask-multi-modal-questions/ask-questions-with-query-language.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.
