Search in sources :

Example 96 with SolrQueryRequest

use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.

the class UpdateLogTest method ulogCommit.

/**
   * Simulate a commit on a given updateLog
   */
private static void ulogCommit(UpdateLog ulog) {
    try (SolrQueryRequest req = req()) {
        CommitUpdateCommand commitCmd = new CommitUpdateCommand(req, false);
        ulog.preCommit(commitCmd);
        ulog.postCommit(commitCmd);
    }
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest)

Example 97 with SolrQueryRequest

use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.

the class UpdateLogTest method ulogAdd.

/**
   * Simulate an add on a given updateLog.
   * <p>
   *   This method, when prevVersion is passed in (i.e. for in-place update), represents an 
   *   AddUpdateCommand that has undergone the merge process and inc/set operations have now been
   *   converted into actual values that just need to be written. 
   * </p>
   * <p>
   * NOTE: For test simplicity, the Solr input document must include the <code>_version_</code> field.
   * </p>
   *
   * @param ulog The UpdateLog to apply a delete against
   * @param prevVersion If non-null, then this AddUpdateCommand represents an in-place update.
   * @param sdoc The document to use for the add.
   * @see #buildAddUpdateCommand
   */
private static void ulogAdd(UpdateLog ulog, Long prevVersion, SolrInputDocument sdoc) {
    try (SolrQueryRequest req = req()) {
        AddUpdateCommand cmd = buildAddUpdateCommand(req, sdoc);
        if (prevVersion != null) {
            cmd.prevVersion = prevVersion;
        }
        ulog.add(cmd);
    }
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest)

Example 98 with SolrQueryRequest

use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.

the class ClassificationUpdateProcessorFactoryTest method init_unsupportedFilterQuery_shouldThrowExceptionWithDetailedMessage.

@Test
public void init_unsupportedFilterQuery_shouldThrowExceptionWithDetailedMessage() {
    UpdateRequestProcessor mockProcessor = mock(UpdateRequestProcessor.class);
    SolrQueryRequest mockRequest = mock(SolrQueryRequest.class);
    SolrQueryResponse mockResponse = mock(SolrQueryResponse.class);
    args.add("knn.filterQuery", "not supported query");
    try {
        cFactoryToTest.init(args);
        /* parsing failure happens because of the mocks, fine enough to check a proper exception propagation */
        cFactoryToTest.getInstance(mockRequest, mockResponse, mockProcessor);
    } catch (SolrException e) {
        assertEquals("Classification UpdateProcessor Training Filter Query: 'not supported query' is not supported", e.getMessage());
    }
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) SolrException(org.apache.solr.common.SolrException) Test(org.junit.Test)

Example 99 with SolrQueryRequest

use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.

the class ClassificationUpdateProcessorIntegrationTest method getDoc.

private Document getDoc(String id) throws IOException {
    try (SolrQueryRequest req = req()) {
        SolrIndexSearcher searcher = req.getSearcher();
        TermQuery query = new TermQuery(new Term(ID, id));
        TopDocs doc1 = searcher.search(query, 1);
        ScoreDoc scoreDoc = doc1.scoreDocs[0];
        return searcher.doc(scoreDoc.doc);
    }
}
Also used : TopDocs(org.apache.lucene.search.TopDocs) TermQuery(org.apache.lucene.search.TermQuery) SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrIndexSearcher(org.apache.solr.search.SolrIndexSearcher) Term(org.apache.lucene.index.Term) ScoreDoc(org.apache.lucene.search.ScoreDoc)

Example 100 with SolrQueryRequest

use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.

the class TestIndexingPerformance method testIndexingPerf.

public void testIndexingPerf() throws IOException {
    int iter = 1000;
    String iterS = System.getProperty("iter");
    if (iterS != null)
        iter = Integer.parseInt(iterS);
    boolean overwrite = Boolean.parseBoolean(System.getProperty("overwrite", "false"));
    String doc = System.getProperty("doc");
    if (doc != null) {
        StrUtils.splitSmart(doc, ",", true);
    }
    SolrQueryRequest req = lrf.makeRequest();
    UpdateHandler updateHandler = req.getCore().getUpdateHandler();
    String field = "textgap";
    String[] fields = { field, "simple", field, "test", field, "how now brown cow", field, "what's that?", field, "radical!", field, "what's all this about, anyway?", field, "just how fast is this text indexing?" };
    /***
    String[] fields = {
            "a_i","1"
            ,"b_i","2"
            ,"c_i","3"
            ,"d_i","4"
            ,"e_i","5"
            ,"f_i","6"
            ,"g_i","7"
            ,"h_i","8"
            ,"i_i","9"
            ,"j_i","0"
            ,"k_i","0"
    };
   ***/
    final RTimer timer = new RTimer();
    AddUpdateCommand add = new AddUpdateCommand(req);
    add.overwrite = overwrite;
    for (int i = 0; i < iter; i++) {
        add.clear();
        add.solrDoc = new SolrInputDocument();
        add.solrDoc.addField("id", Integer.toString(i));
        for (int j = 0; j < fields.length; j += 2) {
            String f = fields[j];
            String val = fields[j + 1];
            add.solrDoc.addField(f, val);
        }
        updateHandler.addDoc(add);
    }
    log.info("doc=" + Arrays.toString(fields));
    double elapsed = timer.getTime();
    log.info("iter=" + iter + " time=" + elapsed + " throughput=" + ((long) iter * 1000) / elapsed);
    //discard all the changes
    updateHandler.rollback(new RollbackUpdateCommand(req));
    req.close();
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrInputDocument(org.apache.solr.common.SolrInputDocument) RTimer(org.apache.solr.util.RTimer)

Aggregations

SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)362 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)148 Test (org.junit.Test)143 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)129 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)106 SolrCore (org.apache.solr.core.SolrCore)58 ArrayList (java.util.ArrayList)49 NamedList (org.apache.solr.common.util.NamedList)48 SolrInputDocument (org.apache.solr.common.SolrInputDocument)45 HashMap (java.util.HashMap)43 AddUpdateCommand (org.apache.solr.update.AddUpdateCommand)37 SolrParams (org.apache.solr.common.params.SolrParams)36 SolrException (org.apache.solr.common.SolrException)34 IOException (java.io.IOException)24 Query (org.apache.lucene.search.Query)24 BufferingRequestProcessor (org.apache.solr.update.processor.BufferingRequestProcessor)24 List (java.util.List)23 MapSolrParams (org.apache.solr.common.params.MapSolrParams)23 ContentStreamBase (org.apache.solr.common.util.ContentStreamBase)23 Map (java.util.Map)22