Chess match database manager IV
This article is the fourth of a series of articles dedicated to the ChessPosDB application, a chess game database manager with a powerful search engine. You can download the application using this link. Here is the link to the first article in this series if you want to start from the beginning. Here, I will finish the section about the search filters by showing the chess match filters. Those filters can include several movement or position filters, which we have already seen in previous posts.
Chess match filters
The movement/position filters search the database for a specific move or position, regardless of the chess match in which it could appear. In contrast, the chess match filters search for matches based on conditions such as the player names, the final result, or a series of movements and positions in a specific order, such as in an opening.
You can build those filters using the same interface as with the movement/position filters, including the option of adding OR filters and AND filters to group various conditions. Use the Match Filter Editor option, in the Database menu, to access the editor:
There is a tool with a drop-down list in which you can select one of the different types of filter, as in the movement/position filter editor:
Match statistics filter
With this filter, you can search for chess matches with a certain value for the count of some events. Currently, the only available event is the number of checks in the game. However, it is possible to add other types of statistics in the future by merely calculating them in the database.
Press the Edit button to select one of the different counts in the dialog box:
The operators you can apply are the same as for the position statistics filters.
Match keyword filter
The chess matches have some tags with text containing information about the game, such as the player names, the match result, the place where the match were played, etc. A keyword identifies each label. With this filter, you can search for games according to the text of one of these labels. You can use a composite filter (AND or OR) to combine several of these filters, for example: White, Karpov; Black, Kasparov; Result, 1-0:
Press the Edit button to open the dialog box to configure this filter:
All the chess matches in the PGN files have some of these keywords and their values. You can also create them using the match editor of this application, which I will explain in another post. The values of those keywords are text strings, so the operators that you can use are different from those for numeric values:
You can specify complex text patterns using regular expressions. If you find this too complicated, you can provide only part of the text and use the Contains or Not Contains operators. The values associated with the same keywords may not contain identical text to specify the same property (for instance, a given player name), so these operators are generally preferable to the Equals operator. Once you have selected the operator, type the text to search or the regular expression pattern in the Value text box and press the OK button.
Match information filter
This filter allows you to combine several of the main standard labels in all the PGN format games in the same operation.
Use the Edit button to display the configuration dialog box:
There is a drop-down list for each tag with the operators you can apply, a text box to write the value, and a button with a red cross to delete the configuration. The search only takes into account the tags with some value. To select a match, it has to meet all the conditions. The White/Black label allows you to combine the Black and White tags if you want to search for a player's name regardless of whether he plays with white or black pieces. All the labels have alphanumeric values, except Ply and Moves, which have numerical values, since they are not keywords, but the total movement count and the move count (a white movement and a black movement).
Movement or position series filter
You can use this filter, combined with the AND filter and the OR filter, to group a series of movement/position filters to specify, for example, the first moves of a particular opening. You can also use it to search for games where a series of combinations occur in a certain order.
You must have previously built some movement/position filters before configuring this kind of filter. You can also use filter collections saved in files, as we will see in the next section. As an example, I have created a couple of simple movement filters: a queen captures a rook, and a queen captures a queen:
The operators used with this filter work with the order number of the movement or position within the chess match. White's first move is move 1, Black's first is move 2, and so on. The position numbers are the number of the movement that produced them:
There are some operators specific for this filter, besides the usual operators such as Equal or Greater than:
- First: this operator indicates that the move or position must be the first in a series, regardless of his order number. You do not have to provide any Value for this operator.
- First +: The number you write in the Value text box is relative to the position/movement number of the one indicated with the First operator. If the value is 1, for instance, this is the one immediately after the first.
- Next: The movement/position order number must be greater than that of the first. For this operator, it is not necessary to provide any value.
- Among the next ...: The movement/position order number must be greater than that of the first but less than or equal to the provided value.
In the following image, you can see an AND filter with two movements: first, a queen captures a rook, and, in the next four moves at most, one queen captures the other queen. In this case, I have not specified the color, so any combination is valid:
Filter collections
This application would not be very useful if you had to rebuild the filters every time you want to make a query. You can save filter collections in XML files, each containing both movement/position and match filters. You can add new filters to an existing filter collection, and you can build match filters using movement/position filters from a collection created previously.
You can add the current filter to a collection using the window toolbar buttons in both filter editors. If you have not yet created a filter collection when you save a filter for the first time, the application creates an empty one:
First, you must type a name for the filter in the corresponding text box to identify it later. You can also provide a longer text description. Next, you have to press the first button next to the Description text box to add it to the filter collection. If you are modifying a previously created filter, use this button to update it in the collection. With the next button, you can add a new copy of the filter to the collection, which can be useful if you build several filters with small differences. The last button is to clear the editor to make a new filter.
The filter collection is on a separate window, which you can see selecting it from the Window menu list:
You can change the name and description of the element selected in the tree using the Name and Description text boxes. The first level is the collection of filters itself; in the second level, there are each of the filters, and in the third one, there are the elements contained in each filter.
You can edit the selected filter using the first button next to the Description text box. The next button is to remove the filter from the collection. In case the selected item is not a filter, these buttons are disabled.
In the File menu, there are options to save and open these filter collection files:
The options to save files are in the menu only when the filter collection window is the selected one. The options to open or create a new collection always appear on the menu.
With this post, I finish the section dedicated to the query filters. In the next article, I will explain how to query the database by applying these filters.
Until next time. Thanks for reading!