After you define the structure of a Visual Query, you can add query conditions to the items in the query structure to look for records with specific values in their properties and metadata.
About this task
When you use Visual Query to search for Information Store records, The conditions on every query item appear in groups that determine how their members are to be combined. You can specify nested levels of grouped conditions to create and run ever more complex search queries.
Note: If you're using Visual Query with an i2 Analyze server at version 4.4.3 or earlier, then the functionality around combining conditions is different from the description below. Refer to the documentation
here instead.
The following example describes how to turn a planned query into a query structure with sets of grouped conditions. Imagine that you want to search for people who are called Ben Steel, but you're not certain about the spelling of "Steel". You know they were born between 1967 and 1979, they own a car, and they hold at least two bank accounts. The car is dark blue or black, and the license plate contains the characters "ABC".
The query structure must take the form of a Person that is connected to a Vehicle with an Access to link. The Person must also be connected to an Account with an Access to link. The Account must be given a count condition.
You must then set the following query conditions:
- On the Account query entity, the count condition must have the value greater than or equal to 2.
- On the Person query entity, you want to specify that one of these conditions is met:
- Family Name is exactly Steele.
- Family Name is exactly Steal.
- Family Name is exactly Steel
AND that one of these conditions is met:
- First (Given) Name is exactly Ben.
- First (Given) Name is exactly Benny.
- First (Given) Name is exactly Benjamin.
AND that this condition is met:
- Year of Birth is between 1967 and 1979.
- On the Vehicle query entity, you want to specify that one of these conditions is met:
- Color is exactly Black.
- Color is exactly Blue.
AND that this condition is met:
- License Plate contains ABC.
Procedure
The
Query conditions pane of a new or open query in the
Visual Query window contains a list of all the items in the query structure. If they have their default names, the items in this example are called Account 1, Person 1, and Vehicle 1.
The requirements say that for the Person 1 query entity, one condition (year of birth) must be met, and there are two groups where one of the member conditions must be met. For the query entity to match a record, all three (the lone condition and the two groups) must be true. Therefore, the default setting for the top-level condition group - Meets all of these conditions - is appropriate here.
-
In the Query conditions list, find the Person 1 query entity, and click Add a condition group . This subgroup is automatically set to use the Meets all of these conditions operator, which is again appropriate here.
-
In the new subgroup, click Add conditions . The Add conditions window opens. Property types are listed first, followed by metadata types.
-
Select Family Name and click OK. The operator for the new condition is set automatically to Is exactly. Type Steel into the text field.
-
Click the Actions button next to Family Name. From the popup menu, click Duplicate. A copy of the condition is added to the group.
Because you're working inside a "Meets at least one..." group, the new condition is prefixed with OR. Amend the name in the text field to Steele.
-
Repeat step 4, and amend the name in the text field to Steal.
-
Return to the top-level condition group for Person 1 and click Add a condition group again. The default operator for this new subgroup is again correct, because the requirements for First Name matching are equivalent to those for Family Name matching.
-
Repeat steps 2, 3, 4, and 5 to add three Is exactly conditions for the First (Given) Name property type, with the values Ben, Benny, and Benjamin.
- Optional:
For conditions that involve some operators and value types, you can enter multiple values instead of creating multiple conditions. To do so:
-
Click the Edit value list button that appears next to the condition value.
-
In the Edit condition values window, enter each value on a separate line.
-
If you have a text file that contains the values that you want to add, you can import it. Click Import text file and browse to the file. Any file that you import must have the file type
.txt
and contain row-separated values.
Note: Value fields in a condition have a maximum number of characters. If you try to import a file that contains too many characters, no text is inserted. Searches are not case-sensitive.
-
Finally, for the Year of Birth condition, return to the top-level condition group once again. This time, click Add conditions instead of Add a condition group.
-
In the Add conditions window, select Date of Birth » Year, and click OK. Change the operator to Between, and then type 1967 and 1979 into the text fields.
The conditions for the Vehicle 1 query entity are simpler than those for Person 1, but similar in structure. There's a lone condition that must be met, and a group in which one of two conditions must be met.
-
Find the Vehicle 1 query entity in the list, and add a condition group to the top-level group. The default operators are again appropriate for your needs here.
-
To the new subgroup, add two new conditions for Vehicle Color. Retain the default Is exactly operators, and type Black into one text field and Blue into the other.
-
Return to the top-level group and a condition for the License Plate Number property type that uses the Contains operator. Type ABC into the text field.
Imagine that at this point, you receive additional information. The vehicle you're interested in might have a license plate containing the characters "ABC", but it might also be "ABO". You need to edit the query accordingly, which means adding a new group and moving the existing condition into it.
-
To the top-level group of the Vehicle 1 query entity, add a new condition group. The subgroup appears at the bottom of the list, below the License Plate Number condition.
-
Use the Move handle next to the License Plate Number condition to drag it into the new subgroup.
Alternatively, click the Actions button next to the condition and select Move down to achieve the same goal.
-
Use the Actions button again to duplicate the condition. Edit ABC to ABO in the text field.
What to do next
When you're happy with the structure and the conditions of the Visual Query, you can run it or save it for later use. If your system administrator has given you the necessary permissions, you can also share it with your colleagues.