You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2014/06/18 01:48:41 UTC

[Solr Wiki] Update of "DocTransformers" by HossMan

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "DocTransformers" page has been changed by HossMan:
https://wiki.apache.org/solr/DocTransformers?action=diff&rev1=7&rev2=8

Comment:
migrated to ef guide

- /!\ EXPERIMENTAL -- Since Solr 4.0
+ {{{#!wiki important
+ This page exists for the Solr Community to share Tips, Tricks, and Advice about 
+ [[https://cwiki.apache.org/confluence/display/solr/Transforming+Result+Documents|DocTransformers]].
  
- Document Transformers give you a way to modify fields that are returned to the user.  For instance, you can use them to include the results of a FunctionQuery or to mark items that have been editorially boosted by the QueryElevationComponent.
+ Reference material previously located on this page has been migrated to the 
+ [[https://cwiki.apache.org/solr/|Official Solr Ref Guide]].
+ If you need help, please consult the ref guide for the version of Solr you are using 
+ for the specific details about using [[https://cwiki.apache.org/confluence/display/solr/Transforming+Result+Documents|this feature]].
  
+ If you'd like to share information about how you use this feature, please [[FrontPage#How_to_edit_this_Wiki|add it to this page]].
+ /* cwikimigrated */
- See also: http://wiki.apache.org/solr/CommonQueryParameters#Transformers:
- 
- <<TableOfContents>>
- 
- == Configuring ==
- You can add a DocTransformer to your application by configuring it in the solrconfig.xml, as in:
- {{{
- <transformer name="elevated" class="org.apache.solr.response.transform.EditorialMarkerFactory" />
  }}}
  
- This will add an instance of the !EditorialMarkerFactory (used to mark items that have been editorially boosted by the QueryElevationComponent so that an application has the option of treating them specially) to the system.  
- 
- Just like other components, you can initialize DocTransformers:
- {{{
- <transformer name="mytrans3" class="org.apache.solr.response.transform.ValueAugmenterFactory" >
-   <double name="defaultValue">5</double>
- </transformer>
- }}}
- See the example solrconfig.xml for other examples of adding transformers.
- 
- == Invoking ==
- 
- To add a transformed field to your results, pass in the name of the configured transformer as a field name, enclosed in brackets in the &fl field list, as in
- {{{
- ...&fl=id,score,[elevated]
- }}}
- 
- In this case, assuming our configuration from above, the EditorialMarkerFactory will be invoked and a new field will be added to the document with the name elevated and a value of true for any document that was editorially boosted.
- 
- You can also pass run time specific values by adding them as attributes inside of the brackets, as in:
- {{{
- ...&fl=id,score,[myTransformer foo=1 bar=good]
- }}}
- 
- <!> TODO: Example of using functions <!>
- 
- == Standard Transformers ==
- 
- By default some transformers are enabled:
- 
- === [explain] ===
- 
- Add explain info to the document.
- 
- can use [explain style=nl], [explain style=text], [explain style=html]
- 
- To configured the default value use:
- {{{
- <transformer name="explain" class="org.apache.solr.response.transform.ExplainAugmenterFactory" >
-   <str name="args">nl</str>
- </transformer>
- }}}
- 
- 
- 
- === [value] ===
- 
- Add a constant value to a document.  For example:
- 
- [value v=hello]
- 
- [value v=10 t=int]
- 
- this can also be configured in the solrconfig.xml with default values.  like:
- {{{
- <transformer name="mytrans2" class="org.apache.solr.response.transform.ValueAugmenterFactory" >
-   <int name="value">5</int>
- </transformer>
- <transformer name="mytrans3" class="org.apache.solr.response.transform.ValueAugmenterFactory" >
-   <double name="defaultValue">5</double>
- </transformer>
- }}}
- 
- 
- 
- === [shard] ===
- 
- will add the shard to the request
- 
- 
- 
- === [docid] ===
- 
- Add the internal docid to the request
-