How do I write an Indication Rule?
Answer
Indication rules are written using drools logic.
Indication rules contain:
- A rule
- At least one condition
- An action
Conditions can be defined at the entire rule level (WHEN), or at a specific action level (IF). The following are conditions that can be used in an indication rule:
- not exists – for data fields
- not existsControl – for control fields
- exists – for control fields
- existsControl – for control fields
- existsMoreThanOnce – for data fields
Then is used following the condition and before the action. When/If the condition is met, then perform the action. The following actions can be used in indication rules:
- set indication."true"
- set indication."false"
Indication rules:
- Begin with the rule
- End with the word end
Conditions and actions apply to record elements. The following record elements can be used in Indication rules:
Record Element | Example |
MARC Field | 650 |
MARC Field_Indicator | 650.{*,0} |
MARC Field_Subfield |
650.a |
MARC Field_Indicator_Subfield | 650.{*,0}.a |
MARC Field_Indicator_Subfield_Value |
650.{*,0}.a.Graphic novels |
MARC Field_Subfield_Value | 650.a.Graphic novels |
Control Field | 007 |
Control Field_Position_Length | 007.{0,4} |
Control Field_Position_Length_Value | 007.{0,4}.v |
Control fields are known as fixed fields. Control fields consist of:
- LDR (leader)
- 00X fields, such as 007, 008
Position_Length:
- The position is the number of the control field
- The length is the number of characters in the position
- The position and length of a control field are enclosed in {brackets}
The value:
- Is the content of the control field and position
Control Field Pattern | Example |
Control Field |
|
Control Field_Position_Length |
|
Control Field_Position_Length_Value |
|
NOTE: Control fields can be opened in the form editor in the MD Editor. Open the fixed field in the MD Editor to view the position and length.
- LDR positions and length can also be found here:https://www.loc.gov/marc/bibliographic/bdleader.html
- The position and length of fixed fields can also be found here: https://www.loc.gov/marc/bibliographic/bd00x.html
Wild Cards & Special Characters
Wild Cards/Special Characters | Definition |
# (hash tag) |
|
* (asterick) |
|
\ (backslash) |
|
. (period) |
|
" " (quotation marks) |
|
Boolan Operators |
|
NOTE: Indication rules cannot contains delimiters ($$) for subfields in the rule. It is recommended to use another character to represent a delimiter, such as | (pipe).
Writing "Simple" Indication Rules:
Indication Rules can be "simple": Indication rules can:
- Contain one or more conditions
- Contain one or more elements
Indication Rule Pattern:
rule
when
condition
then
action
end
Example 1: Find bib records that contain MARC field 490 (series statement). The rule is just looking for bib records that contain a 490.
rule "identify bib records with MARC 490"
when
exists "490"
then
set indication."true"
end
NOTE: Asterisks * can be used to identify all values in a MARC field
exists "5**" - this will find all bib records with notes fields
exists "50*" - this will identify all bib records with notes fields between 500-508
Example 2: Find bib records with MARC 490 $$a. This will find bib records with a 490 $$a.
rule "identify bib records with MARC 490|a"
when
exists "490.a"
then
set indication."true"
end
Example 3: Rule to identify bib record with MARC field 490 $$a with the value of "In a nutshell"
rule "identify records with 490|a|In a nutshell"
when
exists "490.a.In a nutshell"
then
set indication."true"
end
NOTE: An asterisk * can be used to match a string
exists "490.a."nutshell" - this will look for a string that contains nutshell at the end of the series. It may include other series than "In a nutshell.
Example 4: Identify bib records with control field 007
rule "identify records with MARC 007"
when
existsControl "007"
then
set indication."true"
end
Example 5: Identify bib records with control field 007 pos 0 is v for videorecording
rule "identify records with 007|0,1|v"
when
existsControl "007.{0,1}.v"
then
set indication."true"
end
Writing "Complex" Indication Rules:
More "complex" indication rules can be written to combine more than one condition. When you combine more than one condition parenthesis and boolean terms are used in the rule to indicate what conditions need to be met.
Additional Indication Rule Syntax | Definition |
( ) Parenthesis |
Parenthesis are used to enclose conditions or a group of conditions to be met by the rule.
Parenthesis can be used to enclose a group of conditions
|
Boolean Terms |
Boolean terms are used between conditions
|
Example 1: Identify records that were published in 2020 that have a Subject Heading of Graphic novels, but not Comic books
Example 2: Identify records that were published in 2020 and either have a subject heading of Graphic Novels or Comic Books.