This document provides a relatively high level overview to the FlexVertex Voyager language. It covers essential aspects of the language, including basic syntax, key objects, and the most essential methods for each object. If you'd like to learn more about the full FlexVertex reference APIs, consult the FlexVertex Java guide.
Voyager scripts are structured within a Voyage { ... }
block, where queries and commands are defined. Comments are made using //
or /* */
.
There are several reserved words you can use to help users understand your script results when displayed in FlexVertex Commander. They include:
author
: The developer of the script
comment
: Details about the script, your implementation, and so on
tab
: A brief descriptor that will be displayed as a tab title in Commander
title
: The title you'd like displayed across the top of the Commander results
Voyager implements the fluent interface to create more readable and maintainable code by using method chaining. This approach enables the execution of multiple operations in a single line of code through a series of method calls that return the context object itself. The exact order of the methods isn't fixed. In this guide, our code examples will present multiple approaches to writing Voyager scripts, including fluent.
To help you visualize what's possible with FlexVertex and Voyager, imagine you’re building a new app to identify prospective customers for an upcoming travel promotion. You have data about people, their friends, their interests, and places they’ve visited. Your application will examine these objects and connections among them to determine the right results.
This following small, sample collection of information is known as a constellation. Each script in this guide will evaluate all or part of the contents of this constellation.
Whenever feasible, we keep the examples as small and focused as possible.
The combination of the FlexVertex Data Multiverse and Voyager lets you write incrediblly powerful queries with only a few lines of code. For example, the following script answers the question:
Find all direct and up to third degree of separation friends of the person with the highest influencer rating. Only bring back people with an income greater than $100K who’ve taken a special offer package trip to a tropical destination in between March 1 and July 31 2024
Voyage {
// Create the initial Journey Builder
FlexJourneyBuilder jb = journey("select * from Person where InfluencerRating = 98")
.connection() // Search the initial connection to find relevant friends
.name("Friend") // For connections named "Friend"
.target()
.where("Income > 100000") // Filter based on income greater than $100,000
.both() // Consider bidirectional connections between
.evaluate {
// Evaluation block for the initial journey
// Create a nested journey based on the results of the initial journey
FlexJourney j = journey(getTarget())
.connection("Visited") // For connections named "Visited"
.where("VisitDate >= date('2024-03-01') and VisitDate <= date('2024-07-31') and Promotion = true") // Filter based on visit date and promotion
.target()
.where("Type = 'Tropical'") // Filter based on the type being "Tropical"
.explore() // Explore the target
// Check if results exist for the nest journey
if (j.exists()) {
// If it exists, add segments and return true
addSegments(j)
return true
}
// If results for the sub journey does not exist, return false
return false
}
.build() // Build the initial journey
// Perform a breadth-first search on the initial journey
FlexJourney friendsOfInfluencer = breadthFirstSearch(jb, 0, 3, -1)
}
In another instance, this script answers this question:
Where has Marco visited?
Voyage {
return journey("Person where Name='Marco'") // Begin by finding an object with a Name property of 'Marco'
.connection("Visited") // Search for connections from the "Visited" class to find places Marco has visited
.explore() // Execute the journey and return the places Marco has visited
}
Throughout this guide, we'll describe all of the methods - and many others - found in these small Voyager examples.
To get the most from your FlexVertex Voyager experience, it's important to understand some of the most critical objects that it uses to construct searches and then return results. This section provides an introduction to these vital resources.
Journeys are the vehicle that Voyager uses to retrieve information based on your queries.
FlexJourney represents a structured result set that comprises a combination of serialized segments. Each segment within FlexJourney consistently follows a specific sequence that includes a source, a connection, and a target. This ordered sequence is maintained irrespective of whether the source is an origin or a destination. This consistent structuring makes it straightforward to retrieve the segments and navigate through them logically.
In this section, we explore some of the most important methods for FlexJourney objects.
.exists()
true
if there are results, and false
if there are not.Is there a Person named 'Marco'?
Voyage {
exists(journey("Person where Name='Marco'"))
}
Is there a Person named 'Marco' who has a 'Visited' class connection to a location named 'Athens'?
Voyage {
exists (
journey("Person where Name='Marco'") // Start a journey to find an object representing a person named Marco
.connection("Visited") // Evaluate connections of class 'Visited'
.target() // Examine the resulting connection targets
.where("Location = 'Athens'") // To see if the 'Location' property is set to 'Athens'
.build() // Complete the evaluation and generate a FlexJourneyBuilder
)
}
getCount()
How many friends does Nicole have?
Voyage {
var x = journey("Person where Name = 'Nicole'") // Begin by finding a Person object named 'Nicole'
.connection() // Evaluate connections
.name("Friend") // Named 'Friend'
.both() // That are both inbound and outbound (i.e. 'from' and 'to' another object)
.explore() // Process the results
return x.getCount() // Return a count of the results
}
.getSegments()
Which persons have an interest in bonsai or karaoke?
Voyage {
journey("Interest where Type = 'Bonsai' or Type = 'Karaoke'") // Start a journey to find either of these two interests
.connection() // Evaluate connections
.from() // From other objects
.name("Likes") // Where the connections are named 'Likes'
.target("Person") // And they connect from a 'Person' object
.explore() // Explore the results
}
.getSource()
Who has an interest in photography that has taken a business trip to Amsterdam and gone on an escorted canal trip there?
Voyage {
FlexJourney myJourney = journey("Person") // Evaluate objects in the `Person` class
.connection("Business") // Examine the `business` class connection
.target() // For targets of this connection,
.where("Location = 'Amsterdam'") // With a location of `Amsterdam`
.evaluate( // Evaluate
{
FlexJourney canalTrip = journey(getSource()) // Get the source object (the `Person`)
.connection() // Examine the `Taken` name connection
.name("Taken")
.target("Escorted") // Only look at targets of the `Escorted` class
.where("Title = 'Amsterdam Canal Trip'") // With the appropriate `Title`
.explore() // Gather matching segments
FlexJourney likesPhotos = journey(getSource()) // Get the source object (the `Person`)
.connection() // Examine the `Likes` named connection
.name("Likes")
.target("Interest") // Only look at targets of the `Interest` class
.where("Type = 'Photography'") // With the appropriate `Type`
.explore() // Gather matching segments
if((canalTrip.exists()) && (likesPhotos.exists())) // If both nested journeys have results
{
getJourney().addSegments(canalTrip.getSegments()) // Add the canal trip segments
getJourney().addSegments(likesPhotos.getSegments()) // Add the photography interest segments
return true; // Affirm that both nested journeys have results
}
else return false; // Or affirm that they don't
}
)
.explore() // Gather relevant segments
return myJourney // Return the results
}
Which high influencer with an income over $100,000 has a friend - up to 3 degrees away - who has visited a tropical destination between March 1, 2024 and July 31, 2024?
Voyage {
FlexJourneyBuilder jb = journey("Person where InfluencerRating = 98") // Start with a `Person` with a particular `InfluencerRating`
.connection() // Examine the `Friend` named connection
.name("Friend")
.target("Person") // Only look at `Person` objects with `Income` > 100,000
.where("Income > 100000")
.both() // Examine all types of connections
.evaluate { // Evaluate a nested journey
FlexJourney j = journey(getTarget()) // Get the target of each friend connection
.connection("Visited") // Examine `Visited` class connections, evaluating `VisitDate` property on the connections
.where("VisitDate >= date('2024-03-01') and VisitDate <= date('2024-07-31') and Promotion = true")
.target() // Examine the target of the `Visited` connection
.where("Type = 'Tropical'") // For any destinations with the right `Type`
.explore() // Gather segments
if (j.exists()) { // If the segments exist
addSegments(j) // Add them to the journey
return true // And return true
}
return false // Otherwise, return false
}
.build() // Build the journey
FlexJourney friendsOfInfluencer = breadthFirstSearch(jb, 0, 3, -1) // Then, examine the constellation up to 3 degrees of separation away
}
groupEvaluate()
evaluate()
in the context of a journey is called each time a segment is iterated. On the other hand, groupEvaluate()
is typically used to evaluate a collection, usually tied to multiple source objects. There could be many segments inside the journey, yet this method is invoked only once, often to perform a count.What's the least popular destination for leisure trips?
Voyage {
title "What's the least popular destination for leisure trips?"
author "FlexVertex"
comment "This script identifies ithe least popular destination for leisure trips in the multiverse."
tab "Least popular leisure"
FlexJourney j = groupJourney("Destination").groupEvaluate(
{
getGroupJourney().result().addColumn("Destination", getSourceJourney().getSource().getProperty("Location"))
getGroupJourney().result().addColumn("Count", getSourceJourney().getCount())
return true
}).from() // Specify the source of connections, which are the individuals taking leisure trips
.connection("Leisure") // Search for connections named "Leisure" to find leisure trips
.target() // Specify the target of the connections, which are the destinations
.resultOrderBy("Count ASC,Destination ASC") // Order the results by the count of trips in ascending order and destination in ascending order
.explore() // Execute the journey and return the least popular destination for leisure trips
return j.result()
}
groupJourney("group")
//
// Voyage: Who has visited the most places?
// Description: This script identifies individuals who have visited the most places.
Voyage {
// Group individuals by their names and the count of places visited
FlexJourney j = groupJourney("Person")
.groupEvaluate({
getGroupJourney().result().addColumn("Person", getSourceJourney().getSource().getProperty("Name"))
getGroupJourney().result().addColumn("Count", getSourceJourney().getCount())
return true
})
.connection("Visited") // Search for connections labeled as "Visited" to find visited places
.target()
.resultOrderBy("Count DESC,Person ASC") // Order the results by the count of places visited in descending order and then by person's name in ascending order
.explore()
// Return the result with individuals who have visited the most places
return j.result()
}
.result()
FlexResultSet
using the result()
function, it determines how to process the data based on the type of result returned. If a FlexResultSet
is found, it presents the results in a tabular format. However, if a FlexJourney
is returned, it displays the results graphically. In cases where both FlexResultSet
and FlexJourney
results are present, Cartographer will construct both graph and tabular representations, as both formats can coexist.What's the most popular destination in this constellation?
Voyage {
title "What's the most popular destination in this constellation?"
author "FlexVertex"
comment "This script identifies the most popular destination within the given constellation in the multiverse"
tab "Most popular"
FlexJourney j = groupJourney("Destination").groupEvaluate(
{
getGroupJourney().result().addColumn("Destination", getSourceJourney().getSource().getProperty("Location")) // Add "Destination" column from "Location"
getGroupJourney().result().addColumn("Count", getSourceJourney().getCount()) // Add "Count" column from journey count
return true
}).from() // Specify the source of connections, which are the individuals within the given constellation
.connection("Visited") // Search for connections assigned to the "Visited" class to find visited destinations
.target() // Specify the target of the connections, which are the destinations
.resultOrderBy("Count DESC,Destination ASC") // Order the results by the count of visits in descending order and destination in ascending order
.explore() // Execute the journey and return the most popular destination in the constellation
return j.result()
}
.resultOrderBy("order_criteria")
Who has visited the most places?
Voyage {
// Group individuals by their names and the count of places visited
FlexJourney j = groupJourney("Person")
.groupEvaluate({ // Evaluate the following conditions together
getGroupJourney().result().addColumn("Person", getSourceJourney().getSource().getProperty("Name")) // Create a column for the results set from the 'Person' object, 'Name' property
getGroupJourney().result().addColumn("Count", getSourceJourney().getCount()) // Get a count of each place
return true
})
.connection("Visited") // Search for connections assigned to the 'Visited' class
.target() // Examine the targets of the connection
.resultOrderBy("Count DESC,Person ASC") // Order the results by the count of places visited in descending order and then by person's name in ascending order
.explore() // Execute the journey and return the results
return j.result()
}
return
or return object-that-you-wanted-returned
return
statement optional. On the other hand, if you want to return a different object than the last one referenced, specify return
with that object.What are Marco's interests?
Voyage {
journey("Person where Name='Marco'") // Start a journey to find an object representing a person named Marco
.connection() // Search for connections from Marco's object
.name("Likes") // Evaluate those connections named "Likes" to find Marco's interests
.explore() // Execute the journey and return Marco's interests
// This script will automatically return all segments in the journey
}
What are Jade's interests?
Voyage {
return journey("Person where Name='Jade'") // Start a journey to find an object representing a person named Jade
.connection() // Search for connections from Jade's object
.name("Likes") // Evaluate those connections named "Likes" to find Jade's interests
.explore() // Execute the journey and return Jade's interests
// This script explicitly returns all segments in the journey
}
What are はると's interests?
Voyage {
var x = journey("Person where Name='はると'") // Start a journey to find an object representing a person named はると
.connection() // Search for connections from はると's object
.name("Likes") // Evaluate those connections named "Likes" to find はると's interests
.explore() // Execute the journey and return はると's interests
var resultCount = x.getCount()
if (resultCount >= 2)
return x
else
return 'Not enough results'
// This script specifically returns either a journey or a value, depending on the number of results
}
This class is made up of the steps necessary to retrieve a journey. It contains details about the connection and target.
both()
from
and to
) connections.Who are Marco's friends, up to two degrees away?
Voyage {
title "Who are Marco's friends up to two degrees away?"
author "FlexVertex"
comment "Use named 'Friend' connections to find Marco's immediate friends, then view their immediate friends"
tab "Marco's 2nd degree friends"
// Create the initial Journey Builder
FlexJourneyBuilder jb = journey("select * from Person where Name = 'Marco'")
.connection() // Search the initial connection to find relevant friends
.name("Friend") // For connections named "Friend"
.both() // Consider bidirectional connections
.build() // Build the initial journey
// Perform a breadth-first search on the initial journey
FlexJourney friendsOfMarco = breadthFirstSearch(jb, 0, 2, -1)
return friendsOfMarco
}
.build()
build()
to create a FlexJourneyBuilder
that's ready to pass in to explore()
later.Which of Marco's direct and indirect friends have made multiple visits to Istanbul?
Voyage {
// Retrieve information about Marco
var marco = singleQuery("select * from Person where Name='Marco'")
// Use breadth-first search to find Marco's direct and indirect friends
// Use .build() to prepare the journey to be run in the next block of code
FlexJourney friendsOfMarco = breadthFirstSearch(journey(marco).connection().name("Friend").build())
// Group the friends and evaluate if they have made multiple visits to Istanbul
return groupJourney(friendsOfMarco)
.groupEvaluate({
return getSourceJourney().getCount() > 1
})
.connection("Visited") // Search for connections assigned to the "Visited" class from the selected friends
.target()
.where("Location = 'Istanbul'") // Filter connections to include only those with 'Location' property equal to 'Istanbul'
.explore() // Execute the journey and return Marco's friends who have visited Istanbul multiple times
}
.connection()
.connection(FlexJourneyConnection fjc)
.connection(String connectionClass)
.connection(String connectionClass, boolean isPolymorphic)
Who are Marco's friends, up to two degrees away?
Voyage {
title "Who are Marco's friends up to two degrees away?"
author "FlexVertex"
comment "Use named 'Friend' connections to find Marco's immediate friends, then view their immediate friends"
tab "Marco's 2nd degree friends"
// Create the initial Journey Builder
FlexJourneyBuilder jb = journey("select * from Person where Name = 'Marco'")
.connection() // Search the initial connection to find relevant friends
.name("Friend") // For connections named "Friend"
.both() // Consider bidirectional connections
.build() // Build the initial journey
// Perform a breadth-first search on the initial journey
FlexJourney friendsOfMarco = breadthFirstSearch(jb, 0, 2, -1)
return friendsOfMarco
}
.evaluate()
Who has a friend who has taken a trip to Aruba?
Voyage {
title "Who has a friend who has taken a trip to Aruba?"
author "FlexVertex"
comment "Start with the people who have traveled to Aruba. Then, find their friends."
tab "Aruba friends"
FlexJourney myJourney = journey("Person").connection("Visited").target().where("Location = 'Aruba'")
.evaluate(
{
FlexJourney hasFriend = journey(getSource()).connection().name("Friend").explore();
if ((hasFriend.exists()))
{
getJourney().addSegments(hasFriend.getSegments());
return true;
}
else
return false;
})
.explore()
return myJourney;
}
.exclude()
.exclude(java.util.Collection<IFlexObject> collection)
.exclude(FlexExclude copy)
.exclude(FlexJourney j)
.exclude(IFlexObject object)
.exclude(java.lang.String var)
Who has no friends or colleagues?
Voyage {
title "Who has no friends or colleagues?"
author "FlexVertex"
comment "From all persons, find people who have friends and colleagues, then exclude them"
tab "No friends or colleagues"
// Get persons with friends.
FlexJourney hasFriends = journey("Person")
.both() // Search for connections in both directions to find friends
.connection()
.name("Friend") // Evaluate those connections named "Friend"
.explore()
// Get persons with colleagues.
FlexJourney hasColleagues = journey("Person")
.both() // Search for connections in both directions to find friends
.connection()
.name("Colleague") // Evaluate those connections named "Colleague"
.explore()
// Get all persons, exclude those who have friends and colleagues
return journey("Person")
.exclude(hasFriends) // Exclude those people with friends
.exclude(hasColleagues) // Exclude those people with colleagues
.explore() // Execute the journey and return the remainder
}
.target()
.target(String className)
.target(String className, boolean polymorphic)
Which Person(s) has made a leisure trip to Mexico City?
Voyage {
return journey("Person") // Begin by searching for Person objects
.connection("Leisure") // With a connection of class "Leisure"
.target() // Examine the targets of these connections - for any class
.where("Location = 'Mexico City'") // Filter connections to include only those with target destinations where 'Location' property is 'Mexico City'
.explore() // Execute the journey display the results
}
Which Person(s) has made a business trip to a Destination class with a Location property of Istanbul?
Voyage {
return journey("Person") // Begin by searching for Person objects
.connection("Business") // With a connection of class "Business"
.target("Destination") // Examine the targets of these connections - for only the Destination class
.where("Location = 'Istanbul'") // Filter connections to include only those with target destinations where 'Location' property is 'Istanbul'
.explore() // Execute the journey display the results
}
Journeys through your data are comprised of connections and targets. This object contains the properties and methods necessary to determine the connections between instances of your data objects.
both()
from
and to
) connections.For Danielle, display inbound and outbound connections named 'Friend'
Voyage {
journey("Person where Name='Danielle'") // Begin by finding an object named Danielle
.connection() // Evaluate connections
.name("Friend") // Named 'Friend'
.both() // That are both inbound and outbound (i.e. 'from' and 'to' another object)
.explore() // Display the results graphically
}
.exists()
true
if the conditons(s) are met, and false
if they're not. (needs to be adjusted for the context of connection)Is there a Person named 'Marco' with any named 'Likes' connections?
Voyage {
journey("Person where Name='Marco'") // Start a journey to find an object representing a person named Marco
.connection() // Search for connections from Marco's object
.name("Likes") // Evaluate those connections named "Likes"
.exists() // Return a true/false response
}
.from()
from
) connections.For Danielle, display inbound connections named 'Friend'
Voyage {
journey("Person where Name='Danielle'") // Begin by finding an object named Danielle
.connection() // Evaluate connections
.name("Friend") // Named 'Friend'
.from() // That are inbound (i.e. 'from' another object)
.explore() // Display the results graphically
}
.name()
.name(String [connection name]])
Who are Marco's immediate friends, identified by the Name connection?
Voyage
{
return journey("Person where Name='Marco'") // Begin by finding an object with a Name property of 'Marco'
.connection() // Search for connections
.name("Friend") // With an assigned connection name of 'Friend'
.explore() // Execute the journey and return the results
}
Who has provided identification (the connection's class), further qualified by a connection name of Biometric?
Voyage {
// Find individuals who have provided biometric information
// This script combines three different evaluations to satisfy the search criteria
journey("Person") // Begin with 'Person' objects
.connection("HasID") // Search on connections assigned to the 'HasID' class
.name("Biometric") // Further filter on 'HasID' connections named "Biometric" to find individuals with biometric information
.explore()
}
.to()
to
) connections.For Danielle, display outbound connections named 'Friend'
Voyage {
journey("Person where Name='Danielle'") // Begin by finding an object named Danielle
.connection() // Evaluate connections
.name("Friend") // Named 'Friend'
.to() // That are outbound (i.e. 'to' another object)
.explore() // Produce the results
}
where 'condition'
for object filtering, or .where('condition-to-evaluate')
for connectionsFor Danielle, display all connections named 'Friend'?
Voyage {
journey("Person where Name='Danielle'") // Begin by finding a Person object named 'Danielle'
.connection() // Evaluate connections
.name("Friend") // Named 'Friend'
.both() // That are both inbound and outbound (i.e. 'from' and 'to' another object)
.explore() // Produce the results
}
Who has a named 'Friend' connection to and/or from 'Danielle'?
Voyage {
journey("Person") // Begin by finding all Person objects
.connection() // Evaluate connections
.name("Friend") // Named 'Friend'
.both() // That are both inbound and outbound (i.e. 'from' and 'to' another object)
.target() // Evaluate the target
.where("Name = 'Danielle'") // For any connections to 'Danielle'
.explore() // Produce the results
}
Does Nicole have a named 'Friend' connection to Danielle?
Voyage {
journey("Person where Name = 'Nicole'") // Begin by finding a Person object named 'Nicole'
.connection() // Evaluate connections
.name("Friend") // Named 'Friend'
.both() // That are both inbound and outbound (i.e. 'from' and 'to' another object)
.target() // Evaluate the target
.where("Name = 'Danielle'") // For any connections to 'Danielle'
.explore() // Produce the results
}
The internal FlexVertex class supports journeys. A FlexSegment
consists of a source, connection, and target.
addSegments(journey-with-possible-results)
Find all direct and 3 degree of separation friends of the person with the highest influencer rating. Only bring back people with an income > $100K who’ve taken a special offer package trip to a tropical destination in between March 1 and July 31 2024
Voyage {
// Create the initial Journey Builder
FlexJourneyBuilder jb = journey("select * from Person where InfluencerRating = 98")
.connection() // Search the initial connection to find relevant friends
.name("Friend") // For connections named "Friend"
.target()
.where("Income > 100000") // Filter based on income greater than $100,000
.both() // Consider bidirectional connections between
.evaluate {
// Evaluation block for the initial journey
// Create a nested journey based on the results of the initial journey
FlexJourney j = journey(getTarget())
.connection("Visited") // For connections named "Visited"
.where("VisitDate >= date('2024-03-01') and VisitDate <= date('2024-07-31') and Promotion = true") // Filter based on visit date and promotion
.target()
.where("Type = 'Tropical'") // Filter based on the type being "Tropical"
.explore() // Explore the target
// Check if results exist for the nest journey
if (j.exists()) {
// If it exists, add segments and return true
addSegments(j)
return true
}
// If results for the sub journey does not exist, return false
return false
}
.build() // Build the initial journey
// Perform a breadth-first search on the initial journey
FlexJourney friendsOfInfluencer = breadthFirstSearch(jb, 0, 3, -1)
}
These methods are not attached to a given object. Instead, they're used to assist in the overall workflow of a Voyager script.
breadthFirstSearch()
Who are high income friends of the biggest influencer who've taken package trips?
Voyage {
title "Highest influencer friends with high incomes and package trips"
author "FlexVertex"
comment "Objective: Find all direct and 3 degree of separation friends of the person with the highest influencer rating. Only bring back people with an income > 100K who’ve taken a special offer package trip to a tropical destination in between March 1 and July 31 2024 "
tab "High income package trips"
// Create the initial Journey Builder
FlexJourneyBuilder jb = journey("select * from Person where InfluencerRating = 98")
.connection() // Search the initial connection to find relevant friends
.name("Friend") // For connections named "Friend"
.target()
.where("Income > 100000") // Filter based on income greater than $100,000
.both() // Consider bidirectional connections between
.evaluate {
// Evaluation block for the initial journey
// Create a nested journey based on the results of the initial journey
FlexJourney j = journey(getTarget())
.connection("Visited") // For connections named "Visited"
.where("VisitDate >= date('2024-03-01') and VisitDate <= date('2024-07-31') and Promotion = true") // Filter based on visit date and promotion
.target()
.where("Type = 'Tropical'") // Filter based on the type being "Tropical"
.explore() // Explore the target
// Check if results exist for the nest journey
if (j.exists()) {
// If it exists, add segments and return true
addSegments(j)
return true
}
// If results for the sub journey does not exist, return false
return false
}
.build() // Build the initial journey
// Perform a breadth-first search on the initial journey
FlexJourney friendsOfInfluencer = breadthFirstSearch(jb, 0, 3, -1)
}
depthFirstSearch()
Who are high income friends of the biggest influencer who've taken package trips?
Voyage {
title "Highest influencer friends with high incomes and package trips"
author "FlexVertex"
comment "Objective: Find all direct and 3 degree of separation friends of the person with the highest influencer rating. Only bring back people with an income > 100K who’ve taken a special offer package trip to a tropical destination in between March 1 and July 31 2024 "
tab "High income package trips"
// Create the initial Journey Builder
FlexJourneyBuilder jb = journey("select * from Person where InfluencerRating = 98")
.connection() // Search the initial connection to find relevant friends
.name("Friend") // For connections named "Friend"
.target()
.where("Income > 100000") // Filter based on income greater than $100,000
.both() // Consider bidirectional connections between
.evaluate {
// Evaluation block for the initial journey
// Create a nested journey based on the results of the initial journey
FlexJourney j = journey(getTarget())
.connection("Visited") // For connections named "Visited"
.where("VisitDate >= date('2024-03-01') and VisitDate <= date('2024-07-31') and Promotion = true") // Filter based on visit date and promotion
.target()
.where("Type = 'Tropical'") // Filter based on the type being "Tropical"
.explore() // Explore the target
// Check if results exist for the nest journey
if (j.exists()) {
// If it exists, add segments and return true
addSegments(j)
return true
}
// If results for the sub journey does not exist, return false
return false
}
.build() // Build the initial journey
// Perform a breadth-first search on the initial journey
FlexJourney friendsOfInfluencer = depthFirstSearch(jb, 0, 3, -1)
}
.singleQuery(query-that-you-want-to-run)
Who else shares Marco's interests?
Voyage {
var marco = singleQuery("select * from Person where Name='Marco'") // Begin by finding an object with a Name property of 'Marco'
FlexJourney likes = journey(marco) // Build a journey for Marco
.connection() // Examine his connections
.name("Likes") // With an assigned connection name of 'Likes'
.explore() // Explore the results
// Now, search for individuals who share interests similar to Marco, excluding Marco himself
return journey(likes)
.from() // Start the journey from the source of 'likes' connections (individuals who share Marco's interests)
.connection() // Search for connections from these individuals
.name("Likes") // Evaluate those connections named 'Likes'
.target() // Search for destinations of these connections (interests of individuals who share Marco's interests)
.exclude(marco) // Exclude Marco - who was found earlier in singleQuery() - from the results
.explore() // Execute the journey and return individuals who share Marco's interests
}