Example usage for org.apache.solr.request SolrQueryRequestBase SolrQueryRequestBase

List of usage examples for org.apache.solr.request SolrQueryRequestBase SolrQueryRequestBase

Introduction

In this page you can find the example usage for org.apache.solr.request SolrQueryRequestBase SolrQueryRequestBase.

Prototype

public SolrQueryRequestBase(SolrCore core, SolrParams params) 

Source Link

Usage

From source file:lux.solr.SolrDocWriter.java

License:Mozilla Public License

private SolrQueryRequestBase makeSolrQueryRequest() {
    return new SolrQueryRequestBase(core, new ModifiableSolrParams()) {
    };
}

From source file:lux.solr.XQueryComponent.java

License:Mozilla Public License

protected void doCommit() {
    boolean isCloud = shards != null && shards.length > 1;
    SolrQueryRequest req = new SolrQueryRequestBase(core, new ModifiableSolrParams()) {
    };/*from  ww w  . j  a  v  a  2s. c om*/
    CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
    cmd.softCommit = true;
    // cmd.expungeDeletes = false;
    // cmd.waitFlush = true;
    // cmd.waitSearcher = true;
    LoggerFactory.getLogger(getClass()).debug("commit {}", shards);
    try {
        if (isCloud) {
            SolrQueryResponse rsp = new SolrQueryResponse();
            // ((ModifiableSolrParams)req.getParams()).add(ShardParams.SHARDS, getShardURLs(false));
            UpdateRequestProcessorChain updateChain = core.getUpdateProcessingChain("lux-update-chain");
            updateChain.createProcessor(req, rsp).processCommit(cmd);
        } else {
            // commit locally
            core.getUpdateHandler().commit(cmd);
        }
    } catch (IOException e) {
        throw new LuxException(e);
    }
}

From source file:net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector.java

License:Open Source License

/**
 * get a new query request. MUST be closed after usage using close()
 * @param params/*w w  w.j  a  v  a 2  s . c o  m*/
 * @return
 */
public SolrQueryRequest request(final SolrParams params) {
    SolrQueryRequest req = new SolrQueryRequestBase(this.core, params) {
    };
    req.getContext().put("path", SELECT);
    req.getContext().put("webapp", CONTEXT);
    return req;
}

From source file:net.yacy.search.index.SingleDocumentMatcher.java

License:Open Source License

/**
 * @param query a Solr query string to parse
 * @param targetCore an open Solr index core that is the target of the query
 * @return a lucene Query instance parsed from the given Solr query string on the provided Solr core.
 * @throws SyntaxError when the query syntax is not valid
 * @throws SolrException when a query required element is missing, or when a problem occurred when accessing the target core
 *//*  ww  w  .  j  a va  2  s  . c  o m*/
public static Query toLuceneQuery(final String query, final SolrCore targetCore)
        throws SyntaxError, SolrException {
    if (query == null || targetCore == null) {
        throw new IllegalArgumentException("All parameters must be non null");
    }

    final SolrQuery solrQuery = new SolrQuery(query);
    solrQuery.setParam(CommonParams.DF, CollectionSchema.text_t.getSolrFieldName());

    final SolrQueryRequestBase solrRequest = new SolrQueryRequestBase(targetCore, solrQuery) {
    };

    final LuceneQParserPlugin luceneParserPlugin = new LuceneQParserPlugin();
    final QParser solrParser = luceneParserPlugin.createParser(query, null, solrRequest.getParams(),
            solrRequest);
    return solrParser.parse();
}

From source file:org.opensextant.solrtexttagger.AbstractTaggerTest.java

License:Open Source License

/** REMEMBER to close() the result req object. */
protected SolrQueryRequest reqDoc(String doc, SolrParams moreParams) {
    log.debug("Test doc: " + doc);
    SolrParams params = SolrParams.wrapDefaults(moreParams, baseParams);
    SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), params) {
    };/*w ww .  j a  v  a  2 s .c o  m*/
    Iterable<ContentStream> stream = Collections
            .singleton((ContentStream) new ContentStreamBase.StringStream(doc));
    req.setContentStreams(stream);
    return req;
}

From source file:uk.co.flax.biosolr.solr.update.processor.OntologyUpdateProcessorFactoryTest.java

License:Apache License

static void addDoc(String doc, String chain) throws Exception {
    Map<String, String[]> params = new HashMap<>();
    MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
    params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
    SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), mmparams) {
    };//w  w w .  j  av  a  2s  .  c o m

    UpdateRequestHandler handler = new UpdateRequestHandler();
    handler.init(null);
    ArrayList<ContentStream> streams = new ArrayList<>(2);
    streams.add(new ContentStreamBase.StringStream(doc));
    req.setContentStreams(streams);
    handler.handleRequestBody(req, new SolrQueryResponse());
    req.close();
}