Queries allow you to ask more sophisticated questions about the categoriesin your project. For example, you might be interested in how often text marked by one category is also marked by another category. Or you might wish to do a text search only within text marked by a certain category. Queries allow you to explore a project in this way.
To start a query, choose
from the menu. A dialog appears to allow you to create the query:
Each row in the query window specifies one part of the query. Each row corresponds to a clause. Queries can contain many clauses, but at present it is only possible to create queries with two clauses. Each clause retrieves some text passages from the documents in the project. The clauses are joined by operators - 'AND', 'OR', 'AND NOT' - which determine how the text passages from each clause are combined to find the results of the query. The following types of clauses can be used:
Retrieves text coded a category. To choose the category whose coding is to be retrieved, type the first few letters of its name in the dropdown box in the middle of the row. Press Enter to find a list of matching categories, and choose the correct one from the dropdown.
Retrieves text containing a search word. This works very much like a text search.
To compose a query, clauses are joined by operators. These determine how the text passages returned by each clause are combined to make the results of the whole query. The following operators can be used:
Combines two sets of text passages by returning only those passages that are found in both sets.
Combines two sets of text passages by returning text passages that are found in either of the two sets.
Combines the two sets of text passages by returning text that is appears in the first set and doesn't appear in the second set. Put another way, it removes all text passages found in the second set from the first set. Note that unlike "AND" and "OR", the order in which the clauses joined "AND NOT" matters.
To see the results of a query straight away, click the
button at the bottom left of the query window. The results are retrieved, and displayed in the query window's text box. The results can be perused and have coding applied to them.To save the results of a query to a new category, click the
button at the bottom right of the query window. The results are saved to a new category in the category tree under the "SEARCHES" node.To modify the query, click the query tab above the search results. From here, the clauses and operators in the query can be modified and the query re-run.
Say we have a set of interviews in which parents talk about how comfortable and adequate they find their homes for living with children. Some say they find they have a particular need for more space. So we have a category called "Space needs", which we have used to mark all the passages where the interviewees talk about this topic. You've also recorded the age of the children in the house, using categories for different age groups. (see the section called “Using categories to record document attributes”). We particularly want to look at what the families with older, school-age children say.
To turn this is into a query, we want text passages that are from families with school age children: document text CODED BY the category 'Primary school age' OR CODED BY the category 'Secondary school age'. Then within those we want to look at passages CODED BY the category 'Space needs'. So we create the following query: