When using the complex search form in the SCA’s online ordinary & armorial, each line of the search is typically coded with a weight of 1, and most people never change this value, but setting these weights to other values do allow for some interesting search techniques.
A while ago, I asked on SCA Heraldry Unofficial Chat about how how different folks used these weight fields, and have summarized that discussion below.
Weight values are limited to non-negative integers, and may optionally be prefixed with a “+” or “&” character.
The database server considers each criteria line of the search in turn, finds the matching records, and builds up a set of results as follows:
- Records with a positive weight with no prefix are merged in to the set, adding the weight from each match. For example if a criteria line with a weight of 1 matched rows A and B, and a second criteria with a weight of 1 matched rows B and C, the result set would include B with a weight of 2 followed by A and C with weights of 1.
- When records with a prefix of “+” are combined with the set of results from previous matches, only records which are in both sets are kept, and the weights are added as usual. For example if a criteria line with a weight of 1 matched records A and B, and a second criteria with a weight of +1 matched records B and C, the result set would include B with a weight of 2.
- When records with a prefix of “&” are combined with the set of results from previous matches, only records which are in both sets are kept, as they are with “+”, but the weights are overwritten by the new weight rather than added. For example if a criteria line with a weight of 1 matched records A and B, and a second criteria with a weight of &1 matched records B and C, the result set would include B with a weight of 1.
Below are a few ways in which these settings can be used.
If anyone knows of any other cool complex-search-weight tricks, I’d love to hear about them!
Temporarily Ignore A Line
The following technique is useful when running a series of related searches, if you want to temporarily ignore a line but don’t want to blank out the category/feature codes so that you don’t have to re-type them in a subsequent search.
- Set the weight for a criteria line to 0 to remove it from consideration.
Requiring or Emphasizing A Line
The following three techniques are useful to separate items with an SC (substantial change), to make it easier to ignore items that could not possibly conflict and focus on the others. Note that for all of these techniques you need to be sure not to use them on lines which don’t represent an SC, such as tincture, and don’t use them for split-type primaries. If you’re not sure about how to use these techniques, leave the weights at 1 and just check the individual results by hand.
- Set the weight for a criteria line that represents an SC to 2, so that records that don’t match it are at least two points below the maximum possible score.
- Set the weight for a criteria line that represents an SC, or a combination of mutually-exclusive lines, to a large value like 100, so that records that don’t match any of them have a much lower score. As a concrete example, field-primary armory is coded as either FO or PO; a search that includes lines for [ FO weight 100 ] and [ PO weight 100 ] will give all field-primary armory scores of at least 100 so you can ignore everything else.
- Set the weight for a criteria line that represents an SC to “+0” or “+1” to make it as required, which excludes non-matching records from the result set, so you don’t see results that could not possibly conflict. As a concrete example, for armory with a primary charge group of a single type, you can use +0 / +1 as the weight for the primary number line, or on a separate line with just “CATEGORYNAME:primary”, as any items which do not have that number of the primary charge could not possibly conflict. Note that this line must be the last line in your complex search, otherwise the later lines in the search will have their results added regardless of whether they match this criteria.
Analyzing Overlap Between Criteria
The following technique is useful when you have an item which has conflicts, and you’re attempting to figure out which parts of it you might change that would be least likely to introduce new conflicts:
- Set the weight for each successive criteria line to to a weight of 1/10/100/1000/etc (or computer programmers can use 1/2/4/8/etc), and then look at the counts of results for each score to see which combinations of matches are most common.