11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The emailids field in the table can be a comma-separated value. It ends up producing one or more email IDs,<br />

and we expect the mailId to be a multivalued field in <strong>Solr</strong>.<br />

Note that this transformer can either be used to split a string into tokens based on a splitBy pattern, or to perform<br />

a string substitution as per replaceWith, or it can assign groups within a pattern to a list of groupNames. It<br />

decides what it is to do based upon the above attributes splitBy, replaceWith and groupNames which are<br />

looked for in order. This first one found is acted upon and other unrelated attributes are ignored.<br />

The ScriptTransformer<br />

The script transformer allows arbitrary transformer functions to be written in any scripting language supported by<br />

Java, such as Javascript, JRuby, Jython, Groovy, or BeanShell. Javascript is integrated into Java 8; you'll need<br />

to integrate other languages yourself.<br />

Each function you write must accept a row variable (which corresponds to a Java Map , thus<br />

permitting get,put,remove operations). Thus you can modify the value of an existing field or add new fields.<br />

The return value of the function is the returned object.<br />

The script is inserted into the DIH configuration file at the top level and is called once for each row.<br />

Here is a simple example.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

....<br />

<br />

<br />

<br />

The TemplateTransformer<br />

You can use the template transformer to construct or modify a field value, perhaps using the value of other fields.<br />

You can insert extra text into the template.<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

225

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!