Using a core via the Embedded front and the HTTP front end seems dangerous. SOLR-1499 does an HTTP call for the same info.
https://issues.apache.org/jira/browse/SOLR-1499 On Thu, May 6, 2010 at 8:18 PM, Blargy <zman...@hotmail.com> wrote: > > So I came up with the following class. > > public class LatestTimestampEvaluator extends Evaluator { > > private static final Logger logger = > Logger.getLogger(LatestTimestampEvaluator.class.getName()); > > �...@override > public String evaluate(String expression, Context context) { > > List params = EvaluatorBag.parseParams(expression, > context.getVariableResolver()); > String field = params.get(0).toString(); > > SolrCore core = context.getSolrCore(); > CoreContainer container = new CoreContainer(); > container.register(core, false); > EmbeddedSolrServer server = new EmbeddedSolrServer(container, > core.getName()); > > SolrQuery query = new SolrQuery("*:*"); > query.addSortField(field, SolrQuery.ORDER.desc); > query.setRows(1); > > 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(); > logger.info(timestamp); > > return timestamp; > } catch (Exception exception) { > logger.severe(exception.getMessage()); > logger.severe(DocumentUtils.stackTraceToString(exception)); > > return null; > } finally { > core.close(); > container.shutdown(); > } > } > > and I am calling it within my dataconfig file like so... > > <dataConfig> > <function name="latest_timestamp" > class="com.mycompany.solr.handler.dataimport.LatestTimestampEvaluator"/> > ... > > <entity name="item" ... > deltaQuery="select id from items where updated_on > > '${dataimporter.functions.latest_timestamp('updated_on')}' > .... > </entity> > </datConfig> > > 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: > http://lucene.472066.n3.nabble.com/SEVERE-java-util-concurrent-RejectedExecutionException-tp782768p782768.html > > Thanks for your help! > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Custom-DIH-variables-tp777696p782769.html > Sent from the Solr - User mailing list archive at Nabble.com. > -- Lance Norskog goks...@gmail.com