本文整理汇总了Java中org.apache.solr.request.SolrQueryRequest.getCore方法的典型用法代码示例。如果您正苦于以下问题:Java SolrQueryRequest.getCore方法的具体用法?Java SolrQueryRequest.getCore怎么用?Java SolrQueryRequest.getCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.request.SolrQueryRequest
的用法示例。
在下文中一共展示了SolrQueryRequest.getCore方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newFrom
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
* Creates a new {@link SolrQueryRequest} from a given prototype and injects there a set of params.
*
* @param request the prototype {@link SolrQueryRequest}.
* @param params the parameters that will be injected.
* @return a {@link SolrQueryRequest} clone.
*/
public SolrQueryRequest newFrom(final SolrQueryRequest request, final SolrParams params) {
return new SolrQueryRequestBase(
request.getCore(),
new ModifiableSolrParams(params),
new RTimerTree()) {
@Override
public Map<Object, Object> getContext() {
return request.getContext();
}
@Override
public SolrIndexSearcher getSearcher() {
return request.getSearcher();
}
};
}
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:24,代码来源:InvisibleQueriesRequestHandler.java
示例2: ExtractingDocumentLoader
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public ExtractingDocumentLoader(SolrQueryRequest req, UpdateRequestProcessor processor,
TikaConfig config, SolrContentHandlerFactory factory) {
this.params = req.getParams();
this.core = req.getCore();
this.config = config;
this.processor = processor;
templateAdd = new AddUpdateCommand(req);
templateAdd.overwrite = params.getBool(UpdateParams.OVERWRITE, true);
templateAdd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1);
//this is lightweight
autoDetectParser = new AutoDetectParser(config);
this.factory = factory;
ignoreTikaException = params.getBool(ExtractingParams.IGNORE_TIKA_EXCEPTION, false);
}
示例3: calcEtag
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
* Calculates a tag for the ETag header.
*
* @return a tag
*/
public static String calcEtag(final SolrQueryRequest solrReq) {
final SolrCore core = solrReq.getCore();
final long currentIndexVersion
= solrReq.getSearcher().getIndexReader().getVersion();
EtagCacheVal etagCache = etagCoreCache.get(core);
if (null == etagCache) {
final String etagSeed
= core.getSolrConfig().getHttpCachingConfig().getEtagSeed();
etagCache = new EtagCacheVal(etagSeed);
etagCoreCache.put(core, etagCache);
}
return etagCache.calcEtag(currentIndexVersion);
}
示例4: calcLastModified
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
* Calculate the appropriate last-modified time for Solr relative the current request.
*
* @return the timestamp to use as a last modified time.
*/
public static long calcLastModified(final SolrQueryRequest solrReq) {
final SolrCore core = solrReq.getCore();
final SolrIndexSearcher searcher = solrReq.getSearcher();
final LastModFrom lastModFrom
= core.getSolrConfig().getHttpCachingConfig().getLastModFrom();
long lastMod;
try {
// assume default, change if needed (getOpenTime() should be fast)
lastMod =
LastModFrom.DIRLASTMOD == lastModFrom
? IndexDeletionPolicyWrapper.getCommitTimestamp(searcher.getIndexReader().getIndexCommit())
: searcher.getOpenTime();
} catch (IOException e) {
// we're pretty freaking screwed if this happens
throw new SolrException(ErrorCode.SERVER_ERROR, e);
}
// Get the time where the searcher has been opened
// We get rid of the milliseconds because the HTTP header has only
// second granularity
return lastMod - (lastMod % 1000L);
}
示例5: getAndPrepShardHandler
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
private ShardHandler getAndPrepShardHandler(SolrQueryRequest req, ResponseBuilder rb, ShardHandlerFactory shardHandlerFactory) {
ShardHandler shardHandler = null;
boolean isZkAware = false;
CoreContainer cc = null;
if (req.getCore() != null) {
cc = req.getCore().getCoreContainer();
isZkAware = cc.isZooKeeperAware();
}
rb.isDistrib = req.getParams().getBool("distrib", isZkAware);
if (!rb.isDistrib) {
// for back compat, a shards param with URLs like localhost:8983/solr will mean that this
// search is distributed.
final String shards = req.getParams().get(ShardParams.SHARDS);
rb.isDistrib = ((shards != null) && (shards.indexOf('/') > 0));
}
if (rb.isDistrib) {
shardHandler = shardHandlerFactory.getShardHandler();
shardHandler.prepDistributed(rb);
if (!rb.isDistrib) {
shardHandler = null; // request is not distributed after all and so the shard handler is not needed
}
}
if(isZkAware) {
ZkController zkController = cc.getZkController();
NamedList<Object> headers = rb.rsp.getResponseHeader();
if(headers != null) {
headers.add("zkConnected",
zkController != null
? !zkController.getZkClient().getConnectionManager().isLikelyExpired()
: false);
}
}
return shardHandler;
}
示例6: DocBasedVersionConstraintsProcessor
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public DocBasedVersionConstraintsProcessor(String versionField,
boolean ignoreOldUpdates,
String deleteVersionParamName,
boolean useFieldCache,
SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next ) {
super(next);
this.ignoreOldUpdates = ignoreOldUpdates;
this.deleteVersionParamName = deleteVersionParamName;
this.core = req.getCore();
this.versionFieldName = versionField;
this.userVersionField = core.getLatestSchema().getField(versionField);
this.solrVersionField = core.getLatestSchema().getField(VersionInfo.VERSION_FIELD);
this.useFieldCache = useFieldCache;
for (UpdateRequestProcessor proc = next ;proc != null; proc = proc.next) {
if (proc instanceof DistributedUpdateProcessor) {
distribProc = (DistributedUpdateProcessor)proc;
break;
}
}
if (distribProc == null) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "DistributedUpdateProcessor must follow DocBasedVersionConstraintsProcessor");
}
phase = DistributedUpdateProcessor.DistribPhase.parseParam(req.getParams().get(DISTRIB_UPDATE_PARAM));
}
示例7: handleRequestBody
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
{
SolrCore core = req.getCore();
if (core != null) rsp.add( "core", getCoreInfo( core, req.getSchema() ) );
boolean solrCloudMode = getCoreContainer(req, core).isZooKeeperAware();
rsp.add( "mode", solrCloudMode ? "solrcloud" : "std");
rsp.add( "lucene", getLuceneInfo() );
rsp.add( "jvm", getJvmInfo() );
rsp.add( "system", getSystemInfo() );
rsp.setHttpCaching(false);
}
示例8: isHiddenFile
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public static boolean isHiddenFile(SolrQueryRequest req, SolrQueryResponse rsp, String fnameIn, boolean reportError,
Set<String> hiddenFiles) {
String fname = fnameIn.toUpperCase(Locale.ROOT);
if (hiddenFiles.contains(fname) || hiddenFiles.contains("*")) {
if (reportError) {
log.error("Cannot access " + fname);
rsp.setException(new SolrException(SolrException.ErrorCode.FORBIDDEN, "Can not access: " + fnameIn));
}
return true;
}
// This is slightly off, a valid path is something like ./schema.xml. I don't think it's worth the effort though
// to fix it to handle all possibilities though.
if (fname.indexOf("..") >= 0 || fname.startsWith(".")) {
if (reportError) {
log.error("Invalid path: " + fname);
rsp.setException(new SolrException(SolrException.ErrorCode.FORBIDDEN, "Invalid path: " + fnameIn));
}
return true;
}
// Make sure that if the schema is managed, we don't allow editing. Don't really want to put
// this in the init since we're not entirely sure when the managed schema will get initialized relative to this
// handler.
SolrCore core = req.getCore();
IndexSchema schema = core.getLatestSchema();
if (schema instanceof ManagedIndexSchema) {
String managed = schema.getResourceName();
if (fname.equalsIgnoreCase(managed)) {
return true;
}
}
return false;
}
示例9: getAdminFileFromZooKeeper
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public static String getAdminFileFromZooKeeper(SolrQueryRequest req, SolrQueryResponse rsp, SolrZkClient zkClient,
Set<String> hiddenFiles)
throws KeeperException, InterruptedException {
String adminFile = null;
SolrCore core = req.getCore();
final ZkSolrResourceLoader loader = (ZkSolrResourceLoader) core
.getResourceLoader();
String confPath = loader.getCollectionZkPath();
String fname = req.getParams().get("file", null);
if (fname == null) {
adminFile = confPath;
} else {
fname = fname.replace('\\', '/'); // normalize slashes
if (isHiddenFile(req, rsp, fname, true, hiddenFiles)) {
return null;
}
if (fname.startsWith("/")) { // Only files relative to conf are valid
fname = fname.substring(1);
}
adminFile = confPath + "/" + fname;
}
// Make sure the file exists, is readable and is not a hidden file
if (!zkClient.exists(adminFile, true)) {
log.error("Can not find: " + adminFile);
rsp.setException(new SolrException(SolrException.ErrorCode.NOT_FOUND, "Can not find: "
+ adminFile));
return null;
}
return adminFile;
}
示例10: handlePing
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
protected void handlePing(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
{
SolrParams params = req.getParams();
SolrCore core = req.getCore();
// Get the RequestHandler
String qt = params.get( CommonParams.QT );//optional; you get the default otherwise
SolrRequestHandler handler = core.getRequestHandler( qt );
if( handler == null ) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Unknown RequestHandler (qt): "+qt );
}
if( handler instanceof PingRequestHandler ) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Cannot execute the PingRequestHandler recursively" );
}
// Execute the ping query and catch any possible exception
Throwable ex = null;
try {
SolrQueryResponse pingrsp = new SolrQueryResponse();
core.execute(handler, req, pingrsp );
ex = pingrsp.getException();
}
catch( Exception e ) {
ex = e;
}
// Send an error or an 'OK' message (response code will be 200)
if( ex != null ) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Ping query caused exception: "+ex.getMessage(), ex );
}
rsp.add( "status", "OK" );
}
示例11: core
import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
* Returns the {@link SolrCore} associated with the given request.
*
* @param request the current {@link SolrQueryRequest}.
* @return the {@link SolrCore} associated with the given request.
*/
SolrCore core(final SolrQueryRequest request) {
return request.getCore();
}
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:10,代码来源:InvisibleQueriesRequestHandler.java