Composite Queries

By Sandra Schloen, March 2014

A project's Queries tab provides ready-made query templates for the project's users. Many of these queries will provide single-purpose, stand-alone access to project data, but queries can be combined using the Advanced options to create more powerful options for data selection and retrieval. Any of the queries listed as templates are fair game for combining with other queries. It is up to the user to ensure the resulting combination of queries makes sense in some way.

See also Pre-configured Queries.

Consider the following example. Begin by turning on the Advanced options and selecting a Contextual style query.

Choose the "Find loci by context" query as the base query. It will be placed in the center pane with the full set of options provided by the template available to you. In this example you can make selections of Context and Period to be used to restrict the selection of loci. The predefined template properties will further restrict the selection to those items of type "Stratigraphic unit." Notice that at the top of the center pane the query is placed in context, here as the top-most query. On the tabbed pane below, several buttons are available to control the local instance of the query. The local perform-button (with the magnifying glass icon) will run the query independent of any others and will show the number of query results on the count-button.

Next, click the checkbox next to the "Find registered items" query to add it to the specification. It will be added within the context of the currently selected query in the center pane. Note that this query too gets its own local query tab with access to the options made available by this template. Here we can specify both the "Material" and the "Object type" for which to search.

Once again, you can use the local perform-button to run this query independent of its current context. Click the count-button to list just the result of this independent query in the Query Results pane.

Now when we Perform the full contextual query OCHRE will perform the queries in a top-down order, using the results of the higher-level queries to restrict the scope for the lower-level queries. In this case, OCHRE will find the loci that meet the selection criteria of Context and Period (111 of these as it turns out), then restrict the search for matching registered items only to those items contained within these 111 loci. That is, the top-level query determines the context FROM WHICH the subordinate query items will be selected. Our total number of ceramic figurines from the selected loci is 11; these are listed in the Query Results pane.

Other Variations

Consider, instead, if we had wanted to find the Loci that contained Ceramic Figurines. In this case we would toggle the option "FROM WHICH" to the option "THAT CONTAIN" in order to find all Stratigraphic units THAT CONTAIN Registered items that are ceramic figurines. OCHRE would run the query from the bottom-up, first finding all ceramic figurines, then restricting the selection of loci to only those that contained any of the resulting figurine items. To summarize:

  • FROM WHICH: limit the scope from which to find items contained within (top-down)

  • THAT CONTAIN: select items that contain items in the current result set (bottom-up)

Queries can be combined at the same contextual level too. Here we've placed another instance of the "Find registered items" query by using the "+" Advanced option shown above. We would use different criteria on this second instance of this query, say, to find figurines of a zoomorphic style and exclude those.

The toggle options for combining queries at the same level are: COMBINE, INTERSECT, and EXCLUDE. [For those familiar with boolean logic these correspond to the boolean OR, AND, and NOT operations.]

  • COMBINE: include all items from both queries

  • INTERSECT: include only those items that are matched by both queries

  • EXCLUDE: remove from the query results any items resulting from this query

The use of these tools in assorted combinations allows for effective and powerful querying capabilities.