Skip to content

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:

  1. In the Code Browser, right-click on the code you wish to query.

  2. Select either Show in Active Document or Show in All Documents.

    The contextual menu for the Code Browser.
    The contextual menu for the Code Browser.
  3. The matching selections are shown in the Query Results pane.

    The Query Results pane.
    The Query Results pane.
  4. You can save the query to be run later by clicking Save Query in 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 Document Selector in its default, collapsed state.
The Document Selector in its default, collapsed state.

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 empty query builder.
The empty query builder, ready for a query to be built.

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:

  1. Drag a code from the Code Browser onto the Query Builder's canvas; and,

  2. Click and drag on the connection point to connect it to the Results output.

    The query builder with a simple query.
    The query builder with a simple query.
  3. Ensure it is connected the Results node.

Searching for text

To search for a string of text:

  1. Drag the text node onto the canvas.

    The text node.
    The text node.
  2. Insert the text you wish to search for, whether it is case-sensitive, and whether you are looking for a whole word.

  3. 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:

OperatorOutput
ANDOutputs segments where all inputs are met
OROutputs segments where any of the inputs are met
NOTOutputs segments that do not match the inputs
XOROutputs segments where one, but not more, of the inputs are met

To use a logical operator:

  1. Drag the logical operator onto the canvas.

    The logical operator node.
    The logical operator node.
  2. Select the type of logical operator you would like to apply from the drop-down list.

  3. Wire up the inputs you want the logical operator to take.

  4. 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.

OperatorOutput
OverlappingOutputs segments where Code 1 and Code 2 overlap
InsideOutputs segments where Code 1 is fully inside by Code 2
OutsideOutputs segments of Code 1 that do not overlap with Code 2
BeforeOutputs segments of Input 1 where Input 1 ends before Input 2, with no overlap between them
Followed ByOutputs segments of Input 1 where Input 1 starts after Input 2, with no overlap between them
The spatial operator nodes.
The spatial operator nodes.

An example

Imagine you have the following segment of coded text.

A segment of text with a lot of codes applied.
A segment of text with a lot of codes applied.

And

The and logical operator.
The AND logical operator.
Produces:
  • 'Twas his shearing mate who wrote it

Or

The or logical operator.
The OR logical operator.
Produces:
  • 'Twas his shearing mate who wrote it
  • I 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 it
  • Clancy'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

The not logical operator.
The NOT logical operator.
Produces:
  • 'Twas his shearing mate who wrote it
  • Clancy'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

The Xor logical operator.
The XOR logical operator.
Produces:
  • He was shearing when I knew him
  • I 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

The overlapping spatial operator.
The overlapping spatial operator.
Produces:
  • 'Twas his shearing mate who wrote it

Inside

The inside spatial operator.
The inside spatial operator.
Produces:
  • He was shearing when I knew him

Outside

The outside spatial operator.
The outside spatial operator.
Produces:
  • 'Twas his shearing mate who wrote it
  • Clancy's gone to Queensland droving

Before

The before spatial operator.
The before spatial operator.
Produces:
  • He was shearing when I knew him

Followed By

The followed by spatial operator.
The followed by spatial operator.
Produces:
  • (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.

Released under the EUPL.