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.

Transforming Result Documents<br />

Document Transformers can be used to modify the information returned about each documents in the results of<br />

a query.<br />

Using Document Transformers<br />

When executing a request, a document transformer can be used by including it in the fl parameter using square<br />

brackets, for example:<br />

fl=id,name,score,[shard]<br />

Some transformers allow, or require, local parameters which can be specified as key value pairs inside the<br />

brackets:<br />

fl=id,name,score,[explain style=nl]<br />

As with regular fields, you can change the key used when a Transformer adds a field to a document via a prefix:<br />

fl=id,name,score,my_val_a:[value v=42 t=int],my_val_b:[value v=7 t=float]<br />

The sections below discuss exactly what these various transformers do.<br />

Available Transformers<br />

[value] - ValueAugmenterFactory<br />

Modifies every document to include the exact same value, as if it were a stored field in every document:<br />

q=*:*&fl=id,greeting:[value v='hello']<br />

The above query would produce results like the following:<br />

<br />

<br />

1<br />

hello<br />

<br />

...<br />

By default, values are returned as a String, but a " t" parameter can be specified using a value of int, float,<br />

double, or date to force a specific return type:<br />

q=*:*&fl=id,my_number:[value v=42 t=int],my_string:[value v=42]<br />

In addition to using these request parameters, you can configure additional named instances of<br />

ValueAugmenterFactory, or override the default behavior of the existing [value] transformer in your<br />

solrconfig.xml file:<br />

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

333

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

Saved successfully!

Ooh no, something went wrong!