Time for action – adding a custom DocTransformer to hide empty fields in the results

Since DocTransformers can manipulate the data we are going to return for a given document, they can be very useful for adding custom normalizations or simple data manipulations. Looking briefly at how to design a new transformer can add some clarity.

Imagine we had a transformer designed to avoid returning the empty values in our results (in our case there will be several empty fields):

>> curl -X GET 'http://localhost:8983/solr/paintings_transformers/select?q=*:*&fl=*,[noempty]&wt=json&indent=true'

The previous request works if we have added two lines like these in our solrconfig.xml:

<lib dir="${solr.core.instanceDir}/lib/" regex="solr-plugins-java.jar" /> <transformer ...

Get Apache Solr Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.