Strategies
Once you have made your data available as a knowledge graph, you can start querying it using strategies. A strategy is a combination of building blocks that answers a specific query. Each block performs an operation on the knowledge graph (filtering, ranking, transforming, combining, matching, etc). By combining different blocks with each other, strategies that answer queries of any complexity are designed. You create and manage your strategies in this section of Sparque Desk.
The Strategy Editor
The strategy editor is the heart of Sparque Desk. This is were you create and adapt search strategies by combining blocks in the way that solves your search problem. When you create a new strategy, you see an empty canvas, a menu at the top with 'Untitled Strategy' and on the left a library with building blocks.
An empty canvas
The Building Block Library
In the library you find all the building blocks grouped by function. While browsing through the library, you can use the tiptool (under the ?) to inspect the function of a block.
The function of the Filter by Class block
Here you can find the function of all the blocks in the library:
Selecting a Building Block
When you've found the block you need, you simply drag it onto the canvas.
Two unconnected blocks
Two more actions are needed to create a strategy:
connect the block: to other blocks to create a sequence of data navigation and manipulations
configure the block: if configuration is required
Connecting Building Blocks
You connect two blocks by clicking on the small circle at the bottom of a block (the output connector) and by dragging the connecting line onto the small circle at the top of the block (the input connector) to which you want to connect it. Input connectors result in an input to the block, while output connectors result in output being fed to the next block. There may be more than one input or output connector, you can choose one according to your need. Further, an output connector from one block that is connected to an input connector of another block has to be of the same data type. For example an output connector of type Object [OBJ] cannot be connected to an input connector of type String [STRING]. Finally, an output can be connected to multiple inputs.
A strategy
Configuring a Building Block
You can view and change the configuration of a block by clicking it. A dialog opens that shows which parameters need to be or can be configured for the block. For example, with the Filter-block, you are asked to choose what object type (class) to filter on.
Selecting a class to filter on
Inspecting the Output of a Building Block
You can inspect the output of a block by selecting the appropriate output connector. This inspection is very helpful to verify that the operation defined and configured in that block returns the desired results. A test set must be selected (or created) with any input required for a strategy, such as a keyword to search for.
Inspecting the output of a block
Setting the Output of a Strategy
While you have selected an output connector, you can select it as the output of the strategy by clicking the button 'API Output' at the bottom of the result list. When you click the button, the API Output marker is connected to the selected connector:
The API Output marker
By setting the API output, you determine what output the strategy will return via a linked API endpoint. The marker can be connected to any output connector in the strategy, as long as its data type matches the output type defined in the API template. If these types do not match, you will be prompted to update your strategy's API template.
Setting the API output of the strategy
Adding a Strategy Parameter
When you want your strategy to be receptive to external input, you have to define parameter(s) for your strategy and bind them to the parameter of a block. You can do this in two ways: 1) by opening the block you want to connect a strategy parameter to and adding it directly to the block parameter you want to bind it to (depicted below) or 2) by adjusting the API Template of your strategy and selecting the strategy parameter while binding it to a block parameter (explained in the next section).
Adding a new strategy parameter directly to a block parameter
Defining the new strategy parameter
When you add a new strategy parameter in this way, you see the selected block being updated:
Selected block updated with strategy parameter
The API Template of your strategy (in the menu bar at the top of the canvas) reflects the change as well:
The updated API Template
Using a Testset
Once you have bound a strategy parameter to your strategy, you cannot directly view the output of your blocks anymore. A strategy parameter does not have a default value, so instead of a list with results you now see the warning 'no testset selected':
Warning: No testset selected
In order to see results for your strategy again, you have to select a testset for it:
Select a testset
And pick a test from the list:
Pick a test
Defining the API Template
The API Template denotes the parameter(s) that have been defined for the strategy and the type of output it returns. When you create a new strategy, neither has been defined and this is reflected by the lone API Template icon in the menu bar at the top of the canvas:
The initial API Template icon
When you add a strategy parameter or set the API Output for your strategy this is reflected by the API Template being updated. You can also define the API Template of your strategy by clicking on the API Template icon and selecting the template you want it to conform to:
Defining the API template of the strategy
The API Template of your strategy must match the template of the endpoint you want to link it to.
Saving a Version of a Strategy
While you are working on a strategy, you can save interim versions by making snapshots:
Making a new snapshot of a strategy
API endpoints are connected to specific snapshots of your strategy, so they do not immediately change whenever you work on your strategy but only after you've pointed them to a new snapshot. By accessing the version history of a strategy you can revert to pervious versions.
Stacking Strategies
While creating strategies for the different functionalities of your search application, you might find it necessary to design a strategy, that takes the output of another strategy as its input. Consider selecting the relations or properties of a specific set of entities, such as filtering genres for a selection of movies. You want the genres to reflect those of the movies returned by another movie search strategy, rather than all the movies in the dataset. You can achieve this by creating a stacked strategy. Start by selecting the 'Input Block' from the Building Block Library and by designing your strategy accordingly:
A stacked strategy
While you are designing your stacked strategy, it is good practice to use a dataset block as input for your strategy:
Designing a stacked strategy
A stacked strategy can be recognized by its API Template, it starts with OBJ → ... :
The API Template of a stacked strategy
Annotating a Strategy
You can add an annotation to your strategy by clicking the annotation button in the menu in the top left corner of the canvas:
The Annotation Button
You can annotate a combination of blocks by drawing a rectangle around it. Different colors, alignments, and font sizes can be used in an annotation:
An Annotation