Query tab - 23.1

Spectrum Dataflow Designer Guide

Version
23.1
Language
English
Product name
Spectrum Technology Platform
Title
Spectrum Dataflow Designer Guide
Copyright
2024
First publish date
2007
Last updated
2024-10-11
Published on
2024-10-11T22:55:47.128293

Settings on this tab define the query that returns data from the model you select. The model data is returned as data rows in the dataflow output. You can complete options on this tab to build a query, or you can create a custom query. You can also select from or modify existing queries.

Model
Choose the Context Graph model on which to query.
Query
Specifies the query to be used on the model. Select a query from this list box to use or modify an existing model. Select <Custom> to create a new named query, then click Save to enter a name for the query.
If you want to save changes to an existing query but retain the original query, be sure to save the modified query under a new name. Otherwise, you will overwrite the existing query. If you apply a different query to the model or cancel out of the application, changes to the query will be lost.
Use custom query
Select this option to enter code for a custom query instead of configuring the query options on this tab. Custom queries are written in the Neo4j Cypher graph query language.
Input Data
This option is only visible if on the Selection tab, you choose Field for Property value.
Include results from partial traversals
Select this check box to include the results from each step in the query. Leave the box unchecked to include only the results that meet the requirements of the last step. For example, let's say that you are looking at a model that depicts world-wide terrorist activity for the events leading up to September 11, 2001, and you want to return data for any meetings that both Osama bin Laden and Mohamed Atta attended. Your query might include the following steps:
  • An initial step that includes an exact search type for entities with an _stp_id property that has a literal value of Person:Osama bin Laden
  • An Entity to Relationship step of connected with a relationship label of "Meeting"
  • A Relationship to Entity step of connected with a condition of an _stp_id property that contains "Atta"
If you leave the Include results from partial traversals box unchecked, the query would return a single meeting between Osama bin Laden and Mohamed Atta. If you check the box, the query would return all meetings between Osama bin Laden and anyone else in the model. The additional records would be returned because the second step looks for meetings attended by Osama bin Laden and checking the box returns results from each step in the query.
Include results from circular traversals
Select this check box to include elements that occur more than once in each traversal. Uncheck the box to include those elements just once in each traversal. For example, let's say you are using the same model mentioned in step 1, and you initially want to return data for any meetings that Mohamed Atta attended but once you have those results, you want to see all attendees of a particular meeting. Your query might include the following steps:
  • An initial step that includes an exact search type for entities with an _stp_id property that has a literal value of Person:Mohamed Atta, which will return his entity
  • An Entity to Relationship step of connected with a relationship label of "Attended", which will return all events that he attended, including a meeting in Kandahar
  • A Relationship to Entity step of connected with a condition of an Event property that contains "Kandahar", which will return just the Kandahar meeting
  • An Entity to Relationship step of connected with a relationship label of "Attended", which will return relationships that connect to three other entities who attended the meeting in Kandahar and may or may not return the (already traversed) relationship that connects to Mohamed Atta, depending on whether you use this option.
If this check box is selected, Mohamed Atta's relationship will be returned in addition to those for the other three attendees. If you uncheck the box, Mohamed Atta's relationship will not be returned because that relationship (Person:Mohamed Atta->Attended->Meeting:Kandahar) was already traversed in the first step of the query.
Limit results to
Select this check box and enter a number to specify the total maximum number of entities and relationships to return from the query. The default is 5000. The number entered here applies to unique elements, so if the same element appears in multiple results, they will count as one result. If your root step returns a list and you are querying a large model, we strongly suggest entering a limit in this field to prevent the server from becoming unresponsive.
Add Operations
Specify the steps you want the query to take by selecting the appropriate option in the Add Operations drop-down. You can complete this step for the Flow, Conditions, or Output tab. Note that your options vary by whether the root element is an entity or a relationship.
  • If you choose Entity to Entity (valid for All entities and Specify starting entities), you can then refine your search to return data based on relationship labels between two entities (Connected), before entities (Predecessors), or after entities (Successors). For example, if you are querying a model of family members, and you choose a Relationship label of "Father," a Connected query will return all entities that have a Father label between them (in other words, fathers, sons, and daughters). A Predecessors query will return all entities who are a source entity of a Father relationship connected to another entity (in other words, fathers). A Successors query will return all entities who are the target entity of a Father relationship connected to another entity (in other words, sons and daughters).

    As in the root step of your query, you can also select Entity types for this step of the query. You can choose to query selected types or all types. Click Select None to deselect any selected types.

  • If you choose Entity to Relationship (valid for All entities and Specify starting entities), your options are very similar to those for Entity to Entity. You can refine your search to return data based on relationship labels that attach two entities (Connected), occur before entities (Predecessors), or occur after entities (Successors). You can also add conditions to and define output for the query.

  • If you choose Relationship to Entity (valid for All relationships), you can refine your search to return data based on conditions you set. You can return data when a condition is in place for an entity that is connected to another entity (Connected), an entity that is a source to a relationship (Predecessors), and for when an entity is a target of a relationship (Successors). As in the root step of your query, you can also select Entity types for this step of the query. You can choose to query selected types or all types. Click Select None to deselect any selected types.
Regardless of the type of operation you add, you can create Conditions for that operation. You can also define how you want the output from this step to appear. You will notice that steps subsequent to the root step are given a path for output. The path and the step name define the hierarchy of your output data. If you checked the List box in the root step, this path will default to being part of the path in the step before it; however, you can remove the name of the root step. For example, if you named the root step "Locations" and clicked the List box, the first step would by default show "/Locations" in the Path field. (Alternatively, you could remove "Locations" and leave just the slash to have this step originate at the root.) If you called the first step "CountryName", the second step would by default show "/Locations/CountryName" in the Path field and the Locations field output would contain a list of CountryName results. Click the Include in results box if you want the results from this step to be included in the output.

Selection

All entities
Choose this option to query against all entities in a model.
All relationships
Choose this option to query against all relationships in a model.
Specify starting entities
Choose this option to determine at what point in the model you want to begin your search. For example, in a model that has country names for entities, you may choose to examine data for Canada instead of executing the query against all countries. In this case you would select "All" for Search type, select "Country" for Property name, choose Literal, and enter "Germany" for the Property value.
  • Entity types—Click this menu and select the check box next to each type that you want to query. Click Select all to select all check boxes or Select none to clear all check boxes.
  • Search type—Click a search type in the drop-down list. For more information, see Query Search Types (Query Model).
  • Property name—Select a property name from the drop-down list. This list contains all properties associated with the entities and relationships that make up the model.
    Note: You can only query properties that have been indexed; non-indexed properties will not appear in the Property name drop-down.
  • Property value—Specify a property value to query. To search for a literal string, choose Literal and enter a text string search. To search for data in a particular field, choose Field and select the field whose data should be searched. If you choose Field, you must also enter a value in the Input Data grid.
    Note: The value in the Property value field is case sensitive if that field was indexed with the Exact type selected (versus Case insensitive).

    You could also click Field and select "Location" as the Property value, for example, rather than entering a specific value. If you select Field, an Input Data grid containing the name of the field you just selected will appear under the query name along with a cell where you can enter the default value. If you reuse this query elsewhere, you can use the default value you provided in this step, or you can override the default at that time.

Conditions

Complete settings on the Conditions tab if you want to place additional constraints on the query. The Conditions tab has four entry fields:

Logical operator
This field remains empty for the first condition. For subsequent conditions, specify whether this condition should be used in conjunction with previous conditions ("And") or if it should be used instead of previous conditions ("Or").
Data source
Select the property on which the condition will be based.
Operator
Select an operator for the condition that is appropriate for the data type. For more information, see Condition operators (Query Model)
Literal
To use a literal string in the query, choose this option and enter a text string in the Value field.
Field
To use a field value, choose this option and select the field whose data should be searched in the Value field.

In subsequent conditions, select a previous step (such as "Root" or "Step1") and then a property in the Value field to compare property values for the current step against values returned in a previous step.

Note: If you named the output on the Output tab of previous steps, those names will appear in the drop-down rather than "Root" or "Step1".
In this case, the properties shown in the Value field are based on properties for the previous step. For example, if you knew the name of one person (Mohamed Atta) who attended a particular event (a meeting in Kandahar) but wanted to know the names of the other attendees, you could create the following query that includes a property value comparison:
  • A root step that looks for an entity type Person with an _stp_id of that contains "Mohamed"
  • An Entity to Relationship step with a relationship label of "Attended"
  • A Relationship to Entity step with a condition that includes an Event that contains "Kandahar"
  • An Entity to Relationship step with a relationship label of "Attended" plus a condition that this step's _stp_id does not contain the same _stp_id value that was found in the root step.
This query will find that Mohamed Atta attended an event in Kandahar and that it was also attended by three other people whose _stp_id value is not "Mohamed".
Ignore case
Select this check box if the query results can be either upper or lower case.

Output

Include in results
Select this check box if you want the results from this step to be included in the output.
Note: This check box is always selected for the last step in any series. If there is only one step you cannot clear this box.
Specify name
Choose this option to provide a name for this step in the output, choose this option and enter text in the Name field. Using the example from step 3, you might call this step "Afghanistan". Output fields from this step may be named "Afghanistan.Latitude" or "Afghanistan.Date".
Use type name
Choose this option to use the field type as the name for this step in the output. Entities will use entity types and relationships will use relationship labels. Continuing with the same example, output fields with this selection may be named "Person.Latitude" or "Person.Date". If you select this option and enter a name in the Name field, that name will also be added as a prefix for all output fields in addition to the field type. Continuing with the same example, output fields with this selection may be named "Afghanistan.Person.Latitude" or "Afghanistan.Person.Date".
List
Select this check box to use this entry as the name and type of the field in hierarchical output; leave it unchecked to have this entry added as a prefix for all output fields.