lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Blargy <>
Subject Re: Custom DIH variables
Date Fri, 07 May 2010 03:18:38 GMT

So I came up with the following class.

public class LatestTimestampEvaluator extends Evaluator {

  private static final Logger logger =

  public String evaluate(String expression, Context context) {

    List params = EvaluatorBag.parseParams(expression,
    String field = params.get(0).toString();

    SolrCore core = context.getSolrCore();
    CoreContainer container = new CoreContainer();
    container.register(core, false);
    EmbeddedSolrServer server = new EmbeddedSolrServer(container,

    SolrQuery query = new SolrQuery("*:*");
    query.addSortField(field, SolrQuery.ORDER.desc);

    try {
      QueryResponse response = null;
      response = server.query(query);

      SolrDocument document = response.getResults().get(0);
      Date date = (Date) document.getFirstValue(field);
      String timestamp = new Timestamp(date.getTime()).toString();;
      return timestamp;
    } catch (Exception exception) {

      return null;
    } finally {

and I am calling it within my dataconfig file like so...

  <function name="latest_timestamp"

  <entity name="item" ... 
              deltaQuery="select id from items where  updated_on >

I was hoping someone can 

1) Comment on the above class. How does it suck? This was my first time
working with SolrJ.
2) It seems to work find when I there is only one entity using that function
but when there are more entities using that function (which is my use case)
I get a "SEVERE: java.util.concurrent.RejectedExecutionException" exception.
Can someone explain why this is happening and how I can fix it. I added the
full stack trace to a separate thread here:

Thanks for your help!
View this message in context:
Sent from the Solr - User mailing list archive at

View raw message