Search in sources :

Example 31 with SolrParams

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);
            }
        }
    }
}
Also used : NamedList(org.apache.solr.common.util.NamedList) SolrParams(org.apache.solr.common.params.SolrParams) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) List(java.util.List) ArrayList(java.util.ArrayList) NamedList(org.apache.solr.common.util.NamedList)

Example 32 with SolrParams

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);
}
Also used : SolrParams(org.apache.solr.common.params.SolrParams) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) SolrException(org.apache.solr.common.SolrException)

Example 33 with SolrParams

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");
    }
}
Also used : SolrParams(org.apache.solr.common.params.SolrParams) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) SolrSuggester(org.apache.solr.spelling.suggest.SolrSuggester)

Example 34 with SolrParams

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;
}
Also used : SolrParams(org.apache.solr.common.params.SolrParams) MapSolrParams(org.apache.solr.common.params.MapSolrParams) Highlighter(org.apache.lucene.search.highlight.Highlighter) FastVectorHighlighter(org.apache.lucene.search.vectorhighlight.FastVectorHighlighter)

Example 35 with SolrParams

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;
}
Also used : SolrParams(org.apache.solr.common.params.SolrParams) MapSolrParams(org.apache.solr.common.params.MapSolrParams)

Aggregations

SolrParams (org.apache.solr.common.params.SolrParams)310 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)179 SolrException (org.apache.solr.common.SolrException)78 Test (org.junit.Test)45 Tuple (org.apache.solr.client.solrj.io.Tuple)43 SolrDocument (org.apache.solr.common.SolrDocument)42 ArrayList (java.util.ArrayList)41 NamedList (org.apache.solr.common.util.NamedList)40 MapSolrParams (org.apache.solr.common.params.MapSolrParams)37 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)37 IOException (java.io.IOException)35 SolrDocumentList (org.apache.solr.common.SolrDocumentList)34 HashMap (java.util.HashMap)33 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)30 SolrClientCache (org.apache.solr.client.solrj.io.SolrClientCache)27 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)26 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)24 Map (java.util.Map)22 SolrIndexSearcher (org.apache.solr.search.SolrIndexSearcher)22 SolrCore (org.apache.solr.core.SolrCore)20