Building Models in Cogynt Authoring
With the capitals_training.json file uploaded, the next step is to start building a model to process the data. This process consists of the following steps:
- Discovering a schema
- Creating event patterns
- Setting partitions
- Defining outcomes
- Setting computations
Discovering Schemas
Cogynt Authoring's Schema Discovery utility expedites model creation by providing data schemas that are pre-populated with relevant values based on your data. In this step, you'll use the utility to analyze the capitals_training.json data. The utility will then suggest possible schemas for you to use.
To discover a schema:
- Return to Cogynt Authoring by entering the appropriate address in your web browser.
- On the Project homepage, click the system panel (☰) icon.
- Under Other Tasks, click Schema Discovery.
- In the Schema Discovery dialog:
- From the Project dropdown menu, select the project you created (following our example, "Hello World" + your initials).
- From the Kafka Broker dropdown menu, select the default Kafka broker.
- Click Discover.
- In the Discovered Topics list, click the topic you created (following our example, "capitals_" + your initials).
- Click Create User Data Schema.
- In the Create User Data Schema dialog:
- In the Name field, type a name for the schema. (By default, it uses the name of the selected topic.)
- In the Description field, type a description for the schema if necessary.
- Click Create.
If the schema creation is successful, Cogynt displays a confirmation message.
Once you receive the confirmation message, you can move on to creating event patterns.
Creating Event Patterns
The primary unit of logic in a Cogynt model is the event pattern. An event pattern contains pattern detection logic. Users decide what kind of data it should receive, process, and produce for output. For more information about working with event patterns, see System Authoring in the Cogynt Authoring User Guide.
In modeling diagrams, event patterns are represented by event pattern nodes. Models can contain a great many nodes, but this guide's simple model requires only one.
To create an event pattern:
- In Cogynt Authoring, navigate to the diagramming area.
- In the tool palette in the upper-left of the screen, click the Event Pattern icon.
- Click any open space in the diagramming area to place an event pattern node there.
- On the right of the screen, under the Contents tab:
- Type a name for the event pattern in the Name field. (For this exercise, "Hello World" followed by your initials is recommended.)
- In the Description field, type a description. (For this exercise, typing "Training" is recommended.)
- In the diagramming area, double-click the event pattern node you placed in Step 3. The event pattern modeling screen opens.
- In the tool palette, click Add Element (⬭), then click New Event Type.
- In the Create Event Type dialog:
- In the Name field, type a name for the event type. (For this exercise, "Capitals Data" followed by your initials is recommended.)
- From the Topic dropdown menu, select the topic you created (following our example, "capitals_" + your initials).
- From the User Data Schema dropdown menu, select the user data schema you created.
- Click Create.
Once you finish this process, the created event type is added to your model.
The next step is to set partitions on the event pattern for greater data processing precision.
Setting Partitions
A partition instructs the system to analyze events based on a particular field within a specified event pattern. For more information, see Creating Partitions in the Cogynt Authoring User Guide.
To create a partition for your event pattern:
- In Cogynt Authoring, navigate to the diagramming area.
- Click the event pattern node you created.
- In the details panel, click the Contents tab if it is not already selected.
- Under Attributes, click the Partitions section to expand it.
- Confirm that the Enable Partitions toggle is set to "on." (If it is set to "off," click the toggle to set it to the "on" position.)
- Beside the Enable Partitions toggle, click +.
- In the Create Partition dialog:
- From the Elements dropdown menu, select the event pattern you created. (Following our example, it would be "Capitals Data" + your initials.)
- From the Fields dropdown menu, select the field to partition over. For this exercise, select the country_name field. (Note: The Fields dropdown menu cannot be opened until a selection has been made from Elements.)
- Click Create to create.
With the partition set, your pattern will now publish a unique solution for each country in the data set. Workstation will then process each unique solution as a separate record.
The next step is to define an outcome for the event pattern.
Defining Outcomes
An outcome represents output data in a model. Once Cogynt finds a pattern you've defined, an outcome tells the system what to do after that discovery. For more information about outcomes, see Working with Outcomes in the Cogynt Authoring User Guide.
To create an outcome:
- In Cogynt Authoring, navigate to the diagramming area.
- In the diagramming area, click the event pattern node you created.
- In the tool palette, click Add Outcome (▭).
- In the Select Event Type dialog, click New.
- In the Create Event Type dialog:
- In the Name field, type a name for the outcome. (For this exercise, "Hello World Results" is recommended.)
- In the Topic field, enter a Kafka topic name. It is recommended that the Kafka topic name matches what you've entered in the Name field as closely as possible, using underscores (_) instead of spaces. (For this exercise, "hello_world_results" is recommended.)
- From the User Data Schemas dropdown menu, select the schema you previously used.
- Click Create.
Once you have defined an outcome, the next step is to set some computations to process the data points your outcome will generate.
Setting Computations
Cogynt has many built-in computations and functions that make it possible to perform complex calculations or analyses based on inputs from multiple sources.
For this exercise, you'll practice mapping input values to lay the groundwork for computations. After you've finished the entire walkthrough, feel free to return to this section to experiment with computations further.
To add a computation element to your model:
- In Cogynt Authoring, navigate to the diagramming area.
- In the diagramming area, double-click the outcome you created.
- Right-click to open the tool palette.
- In the tool palette, click Map Input Element.
- Click the event pattern you created. (Following our example, it would be "Capitals Data" + your initials.)
- Click any open space in the diagramming area to place the computation element.
- Connect the data fields from the "Capitals Data + initials" input node to the "Hello World Results" output node by clicking and dragging. Establish the following connections:
- capital_name to capital_name
- continent_name to continent_name
- country_code to country_code
- country_name to country_name
- geo_coordinates to geo_coordinates
- When finished, click Hello World in the top navigation bar to return to the event pattern home screen.
With your computations set, you have now configured a complete model. Next, you will deploy your model to start putting it to work.