lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "DIHCustomFunctions" by NoblePaul
Date Thu, 10 Dec 2009 03:42:12 GMT
Dear Wiki user,

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

The "DIHCustomFunctions" page has been changed by NoblePaul.
http://wiki.apache.org/solr/DIHCustomFunctions

--------------------------------------------------

New page:
= Custom Functions for DIH =
It is possible to plug in custom functions into DIH. Implement an [[http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/Evaluator.java?view=markup|Evalutor]]
and specify it in the data-config.xml . Following is an example of an evaluator which does
a 'toLowerCase' on a String.
{{{
<dataConfig>
   <function name="toLowerCase" class="foo.LowerCaseFunctionEvaluator"/>
   <document>
   <entity query="select * from table where name='${dih.functions.toLowerCase(dih.request.user)'">
    <!- ......field declarations......->
   </entity>
</dataConfig>
}}}

The implementation of !LowerCaseFunctionEvaluator
{{{
  public class LowerCaseFunctionEvaluator implements Evaluator{
    public String evaluate(String expression, Context context) {
      List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());

      if (l.size() != 1) {
          throw new RuntimeException("'toLowerCase' must have only one parameter ");
      }
      return l.get(0).toString().toLowerCase();

    }

  }
}}}

Mime
View raw message