Querying
Querying data allows you to see all selections coded with particular codes.
See all selections with a code
To see all selections with a code:
In the Code Browser, right-click on the code you wish to query.
Select either
Show in Active DocumentorShow in All Documents.
The contextual menu for the Code Browser. The matching selections are shown in the Query Results pane.

The Query Results pane. You can save the query to be run later by clicking
Save Queryin the Query Results pane. Magnolia will suggest a name for the query, but you are free to change it.
The Document Selector
The Query tool contains the Document Selector. It can be used to target your query to specific documents.
By default, the Document Selector is collapsed and applies your query to all documents in your project.

The Query Builder
The Query Builder allows you to create complex queries that target specific documents, groups of documents, survey questions, or survey respondents.
To open the Query Builder, click the Query button in the toolbar.
The Document Selector is, by default, collapsed. It will apply your query to all documents unless you specify otherwise.
When a new query is created, the Query Builder is empty.

The Query Builder is a visual, node-based editor. Think of it like a pipeline that you can pour different things into.
To create a query:
Drag a code from the Code Browser onto the Query Builder's canvas; and,
Click and drag on the connection point to connect it to the Results output.

The query builder with a simple query. Ensure it is connected the Results node.
Searching for text
To search for a string of text:
Drag the text node onto the canvas.

The text node. Insert the text you wish to search for, whether it is case-sensitive, and whether you are looking for a whole word.
Ensure it is connected the Results node.
Logical operators
You can add logical operators into your query to refine it. Magnolia uses the common boolean logical operators:
| Operator | Output |
|---|---|
| AND | Outputs segments where all inputs are met |
| OR | Outputs segments where any of the inputs are met |
| NOT | Outputs segments that do not match the inputs |
| XOR | Outputs segments where one, but not more, of the inputs are met |
To use a logical operator:
Drag the logical operator onto the canvas.

The logical operator node. Select the type of logical operator you would like to apply from the drop-down list.
Wire up the inputs you want the logical operator to take.
Ensure it is connected the Results node.
Spatial operators
You can add spatial operators into your query to refine it. Spatial operators return coded segments based on their position in relation to other coded segments.
| Operator | Output |
|---|---|
| Overlapping | Outputs segments where Code 1 and Code 2 overlap |
| Inside | Outputs segments where Code 1 is fully inside by Code 2 |
| Outside | Outputs segments of Code 1 that do not overlap with Code 2 |
| Before | Outputs segments of Input 1 where Input 1 ends before Input 2, with no overlap between them |
| Followed By | Outputs segments of Input 1 where Input 1 starts after Input 2, with no overlap between them |

An example
Imagine you have the following segment of coded text.

And

'Twas his shearing mate who wrote it
Or

'Twas his shearing mate who wrote itI had written him a letter(And I think the same was written with a thumb-nail dipped in tar)'Twas his shearing mate who wrote itClancy's gone to Queensland droving
INFO
In this example, 'Twas his shearing mate who wrote it is returned twice because it matches both Code 1 and Code 2. It is an act of writing about sheep—fulfilling the great Australian literary tradition of writing about these fluffy creatures.
Not

'Twas his shearing mate who wrote itClancy's gone to Queensland droving
INFO
Conceptually, the NOT operator is perhaps the most difficult to understand. This is because it just flips whatever is put into it. This can lead to a lot of output, because it effectively asks Magnolia to "show everything that is not coded with whatever I am putting in".
The example above, while it looks intimidating, is essentially just the same as saying "show me all segments about sheep that are not in the first stanza". You could accomplish this same result in other ways, such as by using the OUTSIDE code.
Xor

He was shearing when I knew himI had written him a letter(And I think the same was written with a thumb-nail dipped in tar)Clancy's gone to Queensland droving
INFO
The Xor logical operator is pronounced "exclusive or". In this example, 'Twas his shearing mate who wrote it is not returned because this segment is both an act of writing and about sheep. It therefore meets both conditions, and because of this, it is excluded (it is not exclusively about sheep or an act of writing).
Overlapping

'Twas his shearing mate who wrote it
Inside

He was shearing when I knew him
Outside

'Twas his shearing mate who wrote itClancy's gone to Queensland droving
Before

He was shearing when I knew him
Followed By

(And I think the same was written with a thumb-nail dipped in tar)
INFO
In this example, 'Twas his shearing mate who wrote it is not returned because the two codes overlap on that segment.