Managing Macros
Viewing Macros
Macros are saved query templates used to simplify and speed up the execution of repetitive search queries in the system.
Access to the macro management page is available through the SAF side menu under the Main
tab. The macros page is a table containing the following columns:
Parameter | Description |
---|---|
Macros Name | The name of the macro, which also serves as its unique identifier (ID). |
Search query text | The text of the search query. Hovering over it allows you to view the full query. |
Arguments | A list of arguments that can be used to configure the macro. This parameter is optional. |
Created Date | Records the creation date of each macro. |
The search bar in the table header allows you to quickly filter macros by name or query text, leaving only the entries that match the criteria.
# Adding a New Macro
You can start creating a macro by clicking the Create
button located in the top right corner of the main table. After clicking, you will be automatically redirected to a page with a form to enter the parameters.
The macro creation form contains the following fields:
Field | Description |
---|---|
Macros Name | Required parameter that serves as the unique identifier for the macro. If arguments are specified, the number of arguments will be automatically displayed in the name after creation. |
Arguments | Optional parameter. Used to pass variable data into the query logic. Arguments are denoted within the query text and escaped with the $ symbol. |
Search query text | Required parameter that contains the main logic of the macro. It can include arguments to configure behavior. |
Example:
-
Name. If the macro is named
simple_macros
and contains one argument, the final name will besimple_macros(1)
. If there are no arguments, the name will remainsimple_macros
. -
Arguments. Example argument:
arg1
. This argument will be used in the query logic. -
Search Query Text. Example query using an argument:
| makeresults count=$arg1$
The value of the argument
arg1
will be substituted into the query when it is executed.
The order of arguments is important when creating and using a macro.
If a macro is created with the name simple_macros(2)
and two arguments in the order arg1
and arg2
, then when calling the macro, it will function like a function where parameters are passed in the specified order.
For example, when calling the macro simple_macros(3,5)
, the value 3
will be automatically substituted into arg1
, and 5
into arg2
. Changing the order of arguments will result in incorrect query logic.
Ensure that parameters are passed strictly in the order specified when creating the macro.
Editing a Macro
To edit an existing macro, find it in the table and click on its name. After clicking, you will be automatically redirected to the editing page with a form to enter parameters. The macro editing form includes fields similar to the creation form, with some differences:
- Macros Name - After creation, this field becomes uneditable as it is used as a unique identifier.
- Arguments - The number of arguments cannot be changed during editing, as it is fixed in the macro name.
- Search query text - This field is editable without restrictions, but it cannot be empty. The query logic can be completely changed when editing. The use of arguments is optional.
If a macro has two arguments, for example arg1
and arg2
, you can rename them, change the order to arg2
and arg1
, or enter new ones like arg4
and arg3
. However, the number of arguments will remain fixed.
If no arguments were specified when creating the macro, they cannot be added during editing.
Using Macros in Search
You can use created macros on the search page by navigating to it and entering the macro name enclosed in backticks (``).
A macro can be used not only with a regular query but also in combination with another macro:
`makeresults(1)``evalLower(2,3)`
Preview Function
If you want to see the content of the query before running it, you can use the following keyboard shortcuts (this function is only available for queries containing macros):
- For Windows: press Ctrl + Shift + E.
- For Mac: use the combination Cmd + Shift + E.
These key combinations open a modal window where you can examine the query content in detail, including the query text from the macro. Use them to ensure the query is correct.
In the window that appears, you will have access to two main buttons:
- Copy request - Clicking this button allows you to copy the expanded query to the clipboard.
- Open in search - Opens a new browser tab with the search page, where the expanded query from the current window is automatically inserted into the search bar, allowing you to continue working with this query.