List of usage examples for org.apache.solr.request SolrRequestInfo getRequestInfo
public static SolrRequestInfo getRequestInfo()
From source file:org.vootoo.schema.CrossCoreField.java
License:Apache License
@Override public ValueSource getValueSource(SchemaField field, QParser parser) { SolrRequestInfo info = SolrRequestInfo.getRequestInfo(); if (info == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cross-core field [" + field.getName() + "] must have SolrRequestInfo"); }/*ww w . j a v a2 s . c om*/ String[] crossCore = dumpCrossSchemaField(field); SchemaField uniqueKeyField = schema.getUniqueKeyField(); final SolrCore targetCore = info.getReq().getCore().getCoreDescriptor().getCoreContainer() .getCore(crossCore[0]); if (targetCore == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cross-core field [" + field.getName() + "] miss target core [" + crossCore[0] + "]"); } SchemaField targetField = targetCore.getLatestSchema().getFieldOrNull(crossCore[1]); if (targetField == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cross-core field [" + field.getName() + "] core [" + crossCore[0] + "] miss field [" + crossCore[1] + "]"); } final RefCounted<SolrIndexSearcher> targetCoreSearcher = targetCore.getSearcher(); SolrIndexSearcher targetSolrIndexSearcher = targetCoreSearcher.get(); CrossCoreFieldValueSource ccfvs = new CrossCoreFieldValueSource(uniqueKeyField, targetField, parser, targetSolrIndexSearcher); info.addCloseHook(new Closeable() { @Override public void close() throws IOException { targetCoreSearcher.decref(); targetCore.close(); } }); return ccfvs; }
From source file:test.DateMathParser.java
License:Apache License
public static TimeZone getTZ(TimeZone tz) { if (null == tz) { SolrRequestInfo reqInfo = SolrRequestInfo.getRequestInfo(); tz = (null != reqInfo) ? reqInfo.getClientTimeZone() : DEFAULT_MATH_TZ; }// w ww.j a v a 2 s. c om return (null != tz) ? tz : DEFAULT_MATH_TZ; }
From source file:test.DateMathParser.java
License:Apache License
/** * Returns a clone of this instance's concept of "now" (never null). * <p>//from ww w. j a va 2 s . c om * If setNow was never called (or if null was specified) then this method * first defines 'now' as the value dictated by the SolrRequestInfo if it * exists -- otherwise it uses a new Date instance at the moment getNow() * is first called. * * @see #setNow * @see SolrRequestInfo#getNOW */ public Date getNow() { if (now == null) { SolrRequestInfo reqInfo = SolrRequestInfo.getRequestInfo(); if (reqInfo == null) { // fall back to current time if no request info set now = new Date(); } else { now = reqInfo.getNOW(); // never null } } return (Date) now.clone(); }