Example usage for org.apache.solr.handler.component ShardRequest PURPOSE_GET_TOP_IDS

List of usage examples for org.apache.solr.handler.component ShardRequest PURPOSE_GET_TOP_IDS

Introduction

In this page you can find the example usage for org.apache.solr.handler.component ShardRequest PURPOSE_GET_TOP_IDS.

Prototype

int PURPOSE_GET_TOP_IDS

To view the source code for org.apache.solr.handler.component ShardRequest PURPOSE_GET_TOP_IDS.

Click Source Link

Usage

From source file:org.alfresco.solr.component.AsyncBuildSuggestComponent.java

License:Open Source License

/** Dispatch shard request in <code>STAGE_EXECUTE_QUERY</code> stage */
@Override/*from  w w  w  .  ja va2 s  .c  o m*/
public int distributedProcess(ResponseBuilder rb) {
    SolrParams params = rb.req.getParams();
    LOG.debug("SuggestComponent distributedProcess with : " + params);
    if (rb.stage < ResponseBuilder.STAGE_EXECUTE_QUERY)
        return ResponseBuilder.STAGE_EXECUTE_QUERY;
    if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
        ShardRequest sreq = new ShardRequest();
        sreq.purpose = ShardRequest.PURPOSE_GET_TOP_IDS;
        sreq.params = new ModifiableSolrParams(rb.req.getParams());
        sreq.params.remove(ShardParams.SHARDS);
        rb.addRequest(this, sreq);
        return ResponseBuilder.STAGE_GET_FIELDS;
    }

    return ResponseBuilder.STAGE_DONE;
}

From source file:org.dice.solrenhancements.spellchecker.DiceSpellCheckComponent.java

License:Apache License

@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
    SolrParams params = rb.req.getParams();
    if (!params.getBool(COMPONENT_NAME, false))
        return;/*from   w  w  w.ja  va 2  s.  c  o  m*/
    int purpose = rb.grouping() ? ShardRequest.PURPOSE_GET_TOP_GROUPS : ShardRequest.PURPOSE_GET_TOP_IDS;
    if ((sreq.purpose & purpose) != 0) {
        // fetch at least 5 suggestions from each shard
        int count = sreq.params.getInt(SPELLCHECK_COUNT, 1);
        if (count < 5)
            count = 5;
        sreq.params.set(SPELLCHECK_COUNT, count);
        sreq.params.set("spellcheck", "true");
    } else {
        sreq.params.set("spellcheck", "false");
    }
}