use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class CdcrRequestHandler method init.
@Override
public void init(NamedList args) {
super.init(args);
if (args != null) {
// Configuration of the Update Log Synchronizer
Object updateLogSynchonizerParam = args.get(CdcrParams.UPDATE_LOG_SYNCHRONIZER_PARAM);
if (updateLogSynchonizerParam != null && updateLogSynchonizerParam instanceof NamedList) {
updateLogSynchronizerConfiguration = SolrParams.toSolrParams((NamedList) updateLogSynchonizerParam);
}
// Configuration of the Replicator
Object replicatorParam = args.get(CdcrParams.REPLICATOR_PARAM);
if (replicatorParam != null && replicatorParam instanceof NamedList) {
replicatorConfiguration = SolrParams.toSolrParams((NamedList) replicatorParam);
}
// Configuration of the Buffer
Object bufferParam = args.get(CdcrParams.BUFFER_PARAM);
if (bufferParam != null && bufferParam instanceof NamedList) {
bufferConfiguration = SolrParams.toSolrParams((NamedList) bufferParam);
}
// Configuration of the Replicas
replicasConfiguration = new HashMap<>();
List replicas = args.getAll(CdcrParams.REPLICA_PARAM);
for (Object replica : replicas) {
if (replica != null && replica instanceof NamedList) {
SolrParams params = SolrParams.toSolrParams((NamedList) replica);
if (!replicasConfiguration.containsKey(params.get(CdcrParams.SOURCE_COLLECTION_PARAM))) {
replicasConfiguration.put(params.get(CdcrParams.SOURCE_COLLECTION_PARAM), new ArrayList<>());
}
replicasConfiguration.get(params.get(CdcrParams.SOURCE_COLLECTION_PARAM)).add(params);
}
}
}
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class CdcrRequestHandler method handleRequestBody.
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
// Pick the action
SolrParams params = req.getParams();
CdcrParams.CdcrAction action = null;
String a = params.get(CommonParams.ACTION);
if (a != null) {
action = CdcrParams.CdcrAction.get(a);
}
if (action == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown action: " + a);
}
switch(action) {
case START:
{
this.handleStartAction(req, rsp);
break;
}
case STOP:
{
this.handleStopAction(req, rsp);
break;
}
case STATUS:
{
this.handleStatusAction(req, rsp);
break;
}
case COLLECTIONCHECKPOINT:
{
this.handleCollectionCheckpointAction(req, rsp);
break;
}
case SHARDCHECKPOINT:
{
this.handleShardCheckpointAction(req, rsp);
break;
}
case ENABLEBUFFER:
{
this.handleEnableBufferAction(req, rsp);
break;
}
case DISABLEBUFFER:
{
this.handleDisableBufferAction(req, rsp);
break;
}
case LASTPROCESSEDVERSION:
{
this.handleLastProcessedVersionAction(req, rsp);
break;
}
case QUEUES:
{
this.handleQueuesAction(req, rsp);
break;
}
case OPS:
{
this.handleOpsAction(req, rsp);
break;
}
case ERRORS:
{
this.handleErrorsAction(req, rsp);
break;
}
case BOOTSTRAP:
{
this.handleBootstrapAction(req, rsp);
break;
}
case BOOTSTRAP_STATUS:
{
this.handleBootstrapStatus(req, rsp);
break;
}
case CANCEL_BOOTSTRAP:
{
this.handleCancelBootstrap(req, rsp);
break;
}
default:
{
throw new RuntimeException("Unknown action: " + action);
}
}
rsp.setHttpCaching(false);
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class SuggestComponent method prepare.
/** Responsible for issuing build and rebuild command to the specified {@link SolrSuggester} */
@Override
public void prepare(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
LOG.info("SuggestComponent prepare with : " + params);
if (!params.getBool(COMPONENT_NAME, false)) {
return;
}
boolean buildAll = params.getBool(SUGGEST_BUILD_ALL, false);
boolean reloadAll = params.getBool(SUGGEST_RELOAD_ALL, false);
final Collection<SolrSuggester> querysuggesters;
if (buildAll || reloadAll) {
querysuggesters = suggesters.values();
} else {
querysuggesters = getSuggesters(params);
}
if (params.getBool(SUGGEST_BUILD, false) || buildAll) {
for (SolrSuggester suggester : querysuggesters) {
suggester.build(rb.req.getCore(), rb.req.getSearcher());
}
rb.rsp.add("command", (!buildAll) ? "build" : "buildAll");
} else if (params.getBool(SUGGEST_RELOAD, false) || reloadAll) {
for (SolrSuggester suggester : querysuggesters) {
suggester.reload(rb.req.getCore(), rb.req.getSearcher());
}
rb.rsp.add("command", (!reloadAll) ? "reload" : "reloadAll");
}
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class TermVectorReusingLeafReader method getPhraseHighlighter.
/**
* Return a phrase {@link org.apache.lucene.search.highlight.Highlighter} appropriate for this field.
* @param query The current Query
* @param fieldName The name of the field
* @param request The current SolrQueryRequest
* @param tokenStream document text tokenStream that implements reset() efficiently (e.g. CachingTokenFilter).
* If it's used, call reset() first.
* @throws IOException If there is a low-level I/O error.
*/
protected Highlighter getPhraseHighlighter(Query query, String fieldName, SolrQueryRequest request, TokenStream tokenStream) throws IOException {
SolrParams params = request.getParams();
Highlighter highlighter = new Highlighter(getFormatter(fieldName, params), getEncoder(fieldName, params), getSpanQueryScorer(query, fieldName, tokenStream, request));
highlighter.setTextFragmenter(getFragmenter(fieldName, params));
return highlighter;
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class TermVectorReusingLeafReader method doHighlightingByFastVectorHighlighter.
/** Highlights and returns the highlight object for this field -- a String[] by default. Null if none. */
@SuppressWarnings("unchecked")
protected Object doHighlightingByFastVectorHighlighter(Document doc, int docId, SchemaField schemaField, FvhContainer fvhContainer, IndexReader reader, SolrQueryRequest req) throws IOException {
SolrParams params = req.getParams();
String fieldName = schemaField.getName();
SolrFragmentsBuilder solrFb = getSolrFragmentsBuilder(fieldName, params);
String[] snippets = fvhContainer.fvh.getBestFragments(fvhContainer.fieldQuery, reader, docId, fieldName, params.getFieldInt(fieldName, HighlightParams.FRAGSIZE, 100), params.getFieldInt(fieldName, HighlightParams.SNIPPETS, 1), getFragListBuilder(fieldName, params), getFragmentsBuilder(fieldName, params), solrFb.getPreTags(params, fieldName), solrFb.getPostTags(params, fieldName), getEncoder(fieldName, params));
if (snippets != null && snippets.length > 0)
return snippets;
return null;
}
Aggregations