Example Queries

Below are examples of queries that illustrate the features of the query language.

"2.4.2." in text

The above searches for any segment where 2.4.2 is a substring of the text field.

"2.4.2." in text and segment_type = "procedure"

Now we further constrain that original text to be only segments with 2.4.2 in their text field and that the segment’s type is procedure.

Queries to the /segments/ endpoint evaluate to lists of segments. Because each segment has regions in the landscape of the collection, we can constrain queries to be relative to those segments:

within ("2.4.2." in text and segment_type = "procedure")

… which is not the segment with 2.4.2 in its text field, but segments in the same physical extent of that segment. Paragraphs, actions, diagrams, etc. can be constrained this way.

within segment_type = "procedure-step" and (within (segment_type = "procedure" and "2-4-2." in text))

As shown above, we can even perform this constraint in the context of a boolean subclause. In this case, we want any segments that are within a procedure-step within the regions of procedure 2.4.2.

(segment_type = "actor" or segment_type = "action") and (within segment_type = "procedure-step" and (within (segment_type = "procedure" and "2-4-2." in text)))

We can filter out specific types of segments in that region based on other attributes too. Above we show filtering based on the segment type. In this case, we fetch actors and actions.

perspective.name = "jobguide_steps" and (within segment_type = "procedure-step" and (within (segment_type = "procedure" and "2-4-2." in text)))

The example above shows filtering on the attribute name of the perspective attribute of the segment. We can access subfields using the . operator to separate fields from their parents.

perspective.name = "tech_manuals" and enrichment_data.confidence_score <= 0.6

The above illustrates using numeric fields with comparison operators. It shows any segments from the tech_manuals perspective that have a lower confidence threshold (60% or lower).

text ~ /GX\d*/

The above example showcases using regular expressions for search. Regular expressions are a powerful syntax for string matching that is widely supported across many applications. A detailed introduction to regular expressions is beyond the scope of this tutorial, but sites like https://regex101.com/.

The above sample matches values of the text field that match GX followed by zero or more of any digit from 0 to 9.

text ~ /(?i)bucket/

The above example also uses regular expressions, but this time performs case-insensitive matches for bucket in any combination by setting a flag for the regular expression. This would include bucket, Bucket, but also bUCket and buckeT.