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:

  1. not exists – for data fields
  2. not existsControl – for control fields
  3. exists – for control fields
  4. existsControl – for control fields
  5. 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: 

  1. set indication."true" 
  2. 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
  • LDR
  • 007
  • 008
Control Field_Position_Length
  • The position:
    • Example for the encoding level in the LDR: Encoding Level 17. Use 17 as the position
    • Example for Date 1 in MARC 008: Date 1  (7-10). Use the first number as the position
  • The length:
    • Example for the encoding level in the LDR: Encoding Level 17. Use the length as the the position is 1 length. LDR.{17,1}
    • Example for Date 1 in MARC 008: Date 1  (7-10). Used 4 as the length because the date takes 4 positions. 008.{7,4}
Control Field_Position_Length_Value
  • The Value:
    • Example find the encoding level of "l" in the LDR: LDR.{17,1}.l

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.

 

Wild Cards & Special Characters 

Wild Cards/Special Characters Definition
# (hash tag)
  • # (hash tags) are used at the beginning of a comment line.
  • The rule ignores lines starting with a # (hash tag)
  • Do not use # (hash tags) for blank indicators
* (asterick)
  • * (asterick) is used to match a string of any length or value including fields, indicators, subfields, and values
  • * (asrertick) can be used before, after, or both to match a string
\ (backslash)
  • \ (backslashes) are used to replace content, except when search for text string with a period at the end
  • \ (backslash) must be used in odd numbers, except when searching for a period at the end of a text string
  • If the value of a subfields ends with a period (.), use four backslashes to match the period, \\\\.
. (period)
  • . (period) is used between fields, indicator, subfields, value (text string)
" " (quotation marks)
  • Rules are written between "quotes"
    • Example; rule "identify records with MARC 650|a|Graphic novels"
  • Record elements in conditions are written between "quotes"
    • Example; exists "650.a.Graphic novels"
  • Actions are enclosed in "quotes"
    • Example; set indication."true"
Boolan Operators
  • AND and OR can be used between conditions in indication rules

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

 

DO NOT copy and paste indication rule examples from Ex Libris or other documentation because it may copy incorrectly causing a syntax error upon saving the rule. It is better to type the rule directly into the MD Editor.

 

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. 

  • (exists "264.c.2020") AND (not exists "505")

Parenthesis can be used to enclose a group of conditions

  • ((exists "264.c.2020") AND (exists "650.{*,*}.a.Graphic novels") AND (not exists "650.{*,*}.v.Comic books*"))
Boolean Terms

Boolean terms are used between conditions

  • AND
  • OR

 

Example 1: Identify records that were published in 2020 that have a Subject Heading of Graphic novels, but not Comic books

rule "identify records published 264|c|2020 with 650|*0|a|Graphic novels but not 650|*,0|v|Comic books"
when
((exists "264.c.2020") AND (exists "650.{*,*}.a.Graphic novels") AND (not exists "650.{*,*}.v.Comic books*"))
then
set indication."true"
end
 
 

Example 2: Identify records that were published in 2020 and either have a subject heading of Graphic Novels or Comic Books. 

rule "identify records published 2020 with 650|*0|a|Graphic novels and 650|*,0|v|Comic books"
when
(exists "264.c.2020") AND ((exists "650.{*,*}.a.Graphic novels") OR (exists "650.{*,*}.v.Comic books*"))
then
set indication."true"
end 

View the Indication Rules LibGuide for more information:https://sunyolis.libguides.com/c.php?g=986218&p=7132450
  • Last Updated Jul 20, 2023
  • Views 305
  • Answered By Margaret McGee

FAQ Actions

Was this helpful? 0 0