Adding a Modifying Script manipulator to a crawl

A Modifying Script manipulator runs an inline BeanShell script that modifies Endeca records. You add and configure a Modifying Script manipulator inside a manipulatorConfig element of the crawl configuration file, and you identify the manipulator with a moduleId of com.endeca.ias.manipulator.ModifierScriptManipulator.

The manipulator has access to the methods in the Record and PropertyValue classes (i.e., com.endeca.eidi.record and com.endeca.eidi.record.PropertyValue). For details about the methods in these classes, see the IAS Record Store API Reference (Javadoc) installed in IAS\<version>\doc\recordstore-javadoc. The manipulator also has access to the methods in the Logger class in org.slf4j.Logger. Other classes may be imported as necessary.

The manipulator supports BeanShell 2.0b4 and later. For more information about BeanShell scripting, see http://www.beanshell.org.

To add a Modifying Script manipulator to a crawl:

  1. Open the crawl configuration file in a text editor.
  2. Locate the manipulatorConfigs element.

    (This element is a container for one or more manipulatorConfig components.)

  3. Inside the manipulatorConfigs element, add the following XML to specify a default Modifying Script manipulator:
    <manipulatorConfig>
    				<moduleId>
    					<id>com.endeca.ias.manipulator.ModifierScriptManipulator</id>
    				</moduleId>
    				<moduleProperties>
    					<moduleProperty>
    						<key>scriptSource</key>
    						<value>idPropertyValue = record.getPropertySingleValue("Endeca.Id");
    						record.addPropertyValue(new PropertyValue("New.Prop", "IAS"));
    						logger.info("Processed Record:" + idPropertyValue.Value);</value>
    					</moduleProperty>
    				</moduleProperties>
    				<id>addIASPropertyManipulator</id>
    </manipulatorConfig>
  4. Configure the following settings:
    Option Name Option Description
    moduleId (Required). Specify the ID for a Modifying Script manipulator. This value must be set to com.endeca.ias.manipulator.ModifierScriptManipulator.
    scriptSource (Required). Specify the inline BeanShell script to perform modifying operations. The example script, provided in the defaultValue element, adds a property to each record being crawled and then logs that addition. You can modify the inline script as appropriate for your crawl.
    id (Required). Specify the ID for this instance of a Modifying Script manipulator.
  5. Save and close the crawl configuration file.
  6. Run either the createCrawls task or the updateCrawls of ias-cmd to upload the crawl configuration file to IAS.