当前位置: 首页>>代码示例>>Java>>正文


Java UpdateRequest.setParam方法代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.request.UpdateRequest.setParam方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateRequest.setParam方法的具体用法?Java UpdateRequest.setParam怎么用?Java UpdateRequest.setParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.client.solrj.request.UpdateRequest的用法示例。


在下文中一共展示了UpdateRequest.setParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertTestDocuments

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
private void insertTestDocuments (int n, int nkids, boolean preserveDV) throws Exception {
  UpdateRequest req = new UpdateRequest();
  req.setPath(UPDATE_DOCVALUES);
  if (preserveDV) {
    req.setParam(UpdateDocValuesProcessor.UPDATEDV_VALUE_FIELD, WEIGHT_DV);
  }
  for (int i = 1; i <= n; i++) {
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField(URI, uri(i));
    doc.addField(TEXT_FIELD, "This is document " + i);
    // NOTE: must provide a value for at least one document in order to create the field:
    // it's not enough to just put it in the solr schema
    if (! preserveDV) {
      doc.addField(WEIGHT_DV, 0);
    }
    for (int j = 1; j <= nkids; j++) {
      SolrInputDocument kid = new SolrInputDocument();
      kid.addField(URI, uriChild(i, j));
      kid.addField(TEXT_FIELD, "This is child document " + i + "/" + j);
      doc.addChildDocument(kid);
    }
    req.add(doc);
  }
  solr.request(req);
  solr.commit(false, true, true);
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:27,代码来源:UpdateDocValuesTest.java

示例2: indexDocumentAndWaitForSync

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
private void indexDocumentAndWaitForSync(String docId) {
    final SolrInputDocument doc = new SolrInputDocument();
    doc.setField("id", docId);
    final UpdateRequest docUpdate = new UpdateRequest();
    docUpdate.add(doc);
    docUpdate.setParam(UpdateParams.COLLECTION, COLLECTION_NAME);
    docUpdate.setWaitSearcher(true);
    docUpdate.setParam(UpdateParams.SOFT_COMMIT, Boolean.TRUE.toString());
    try {
        final UpdateResponse response = docUpdate.process(solrClient);
        assertThat(response.getStatus()).isEqualTo(0);
        SolrCloudUtils.waitForReplicasToSync(COLLECTION_NAME, solrClient, WAIT_TIMEOUT_SECONDS);
    } catch (SolrServerException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:shaie,项目名称:lucenelab,代码行数:17,代码来源:MiniSolrCloudClusterTest.java

示例3: indexDocumentAndWaitForSync

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
private void indexDocumentAndWaitForSync(String docId, String collectionName) {
    final SolrInputDocument doc = new SolrInputDocument();
    doc.setField("id", docId);
    final UpdateRequest docUpdate = new UpdateRequest();
    docUpdate.add(doc);
    docUpdate.setParam(UpdateParams.COLLECTION, collectionName);
    docUpdate.setWaitSearcher(true);
    docUpdate.setParam(UpdateParams.SOFT_COMMIT, Boolean.TRUE.toString());
    try {
        final UpdateResponse response = docUpdate.process(solrClient);
        assertThat(response.getStatus()).isEqualTo(0);
        SolrCloudUtils.waitForReplicasToSync(collectionName, solrClient, WAIT_TIMEOUT_SECONDS);
    } catch (SolrServerException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:shaie,项目名称:lucenelab,代码行数:17,代码来源:AutoAddReplicaTest.java

示例4: importRecord

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
private static void importRecord(String rec) throws SolrServerException, IOException, JSONException {

        // System.out.println(">>> Import a record ");

        // JSON record erzeugen ...
        JSONObject o = parseJSON(rec);

        SolrInputDocument document = new SolrInputDocument();

        Iterator k = o.keys();
        while (k.hasNext()) {
            String key = (String) k.next();
//                System.out.println( key + "  " + o.get(key).toString() );
            document.addField(key, o.get(key).toString());
        }

        
        UpdateRequest add = new UpdateRequest();
        add.add(document);
        add.setCommitWithin(30000);
        add.setParam("collection", collection);
        add.process(solr);
    }
 
开发者ID:kamir,项目名称:MorphMiner,代码行数:24,代码来源:ResultLineImporter.java

示例5: testUpdateRequestWithParameters

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Test
public void testUpdateRequestWithParameters() throws Exception {
  SolrServer server1 = createNewSolrServer();
  
  server1.deleteByQuery( "*:*" );
  server1.commit();
  
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField("id", "id1");
  
  UpdateRequest req = new UpdateRequest();
  req.setParam("overwrite", "false");
  req.add(doc);
  server1.request(req);
  server1.request(req);
  server1.commit();
  
  SolrQuery query = new SolrQuery();
  query.setQuery("*:*");
  QueryResponse rsp = server1.query(query);
  
  SolrDocumentList out = rsp.getResults();
  assertEquals(2, out.getNumFound());
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:SolrExampleTests.java

示例6: process

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Override
protected void process(String topic, UpdateRequest updateRequest) throws IOException, SolrServerException {
  final String collection = collection(topic);
  updateRequest.setParam("collection", collection);
  UpdateResponse response = updateRequest.process(client);
  log.trace("process() - qtime = {} elapsedTime = {}", response.getQTime(), response.getElapsedTime());
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-solr,代码行数:8,代码来源:CloudSolrSinkTask.java

示例7: testUpdateRequestWithParameters

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Test
public void testUpdateRequestWithParameters() throws Exception {
  SolrServer server1 = createNewSolrServer();
  
  server1.deleteByQuery( "*:*" );
  server1.commit();
  
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField("id", "id1");
  
  UpdateRequest req = new UpdateRequest();
  req.setParam("overwrite", "false");
  req.add(doc);
  server1.request(req);
  server1.request(req);
  server1.commit();
  
  SolrQuery query = new SolrQuery();
  query.setQuery("*:*");
  QueryResponse rsp = server1.query(query);
  
  SolrDocumentList out = rsp.getResults();
  assertEquals(2, out.getNumFound());
  if (!(server1 instanceof EmbeddedSolrServer)) {
    /* Do not shutdown in case of using EmbeddedSolrServer, 
     * as that would shutdown the CoreContainer */
    server1.shutdown();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:SolrExampleTests.java

示例8: indexDoc

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Override
protected void indexDoc(SolrInputDocument doc) throws IOException,
    SolrServerException {
  
  UpdateRequest req = new UpdateRequest();
  req.add(doc);
  req.setParam("CONTROL", "TRUE");
  req.process(controlClient);
  
  // if we wanted to randomly pick a client - but sometimes they may be
  // down...
  
  // boolean pick = random.nextBoolean();
  //
  // int which = (doc.getField(id).toString().hashCode() & 0x7fffffff) %
  // sliceCount;
  //
  // if (pick && sliceCount > 1) {
  // which = which + ((shardCount / sliceCount) *
  // random.nextInt(sliceCount-1));
  // }
  //
  // HttpSolrServer client = (HttpSolrServer)
  // clients.get(which);
  
  UpdateRequest ureq = new UpdateRequest();
  ureq.add(doc);
  // ureq.setParam(UpdateParams.UPDATE_CHAIN, DISTRIB_UPDATE_CHAIN);
  ureq.process(cloudClient);
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:AbstractFullDistribZkTestBase.java

示例9: indexDoc

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
protected void indexDoc(SolrInputDocument doc) throws IOException,
    SolrServerException {
  
  if (controlClient != null) {
    UpdateRequest req = new UpdateRequest();
    req.add(doc);
    req.setParam("CONTROL", "TRUE");
    req.process(controlClient);
  }

  
  UpdateRequest ureq = new UpdateRequest();
  ureq.add(doc);
  ureq.process(cloudClient);
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:StopableIndexingThread.java

示例10: vdelete

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
void vdelete(String id, long version, String... params) throws Exception {
  UpdateRequest req = new UpdateRequest();
  req.deleteById(id);
  req.setParam("del_version", Long.toString(version));
  for (int i=0; i<params.length; i+=2) {
    req.setParam( params[i], params[i+1]);
  }
  ss.request(req);
  // req.process(cloudClient);
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TestDistribDocBasedVersion.java

示例11: vadd

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
void vadd(String id, long version, String... params) throws Exception {
  UpdateRequest req = new UpdateRequest();
  req.add(sdoc("id", id, vfield, version));
  for (int i=0; i<params.length; i+=2) {
    req.setParam( params[i], params[i+1]);
  }
  ss.request(req);
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestDistribDocBasedVersion.java

示例12: sendDoc

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
protected void sendDoc(int docId) throws Exception {
  UpdateRequest up = new UpdateRequest();
  up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(2));
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField(id, String.valueOf(docId));
  doc.addField("a_t", "hello" + docId);
  up.add(doc);
  int minAchievedRf =
      cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), cloudClient.request(up));
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:HttpPartitionTest.java

示例13: sendDoc

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
protected int sendDoc(int docId, int minRf) throws Exception {
  UpdateRequest up = new UpdateRequest();
  up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(minRf));
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField(id, String.valueOf(docId));
  doc.addField("a_t", "hello" + docId);
  up.add(doc);
  return cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), cloudClient.request(up));
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:ReplicationFactorTest.java

示例14: updateDocValues

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
private UpdateRequest updateDocValues () {
  UpdateRequest req = new UpdateRequest();
  req.setParam(UpdateDocValuesProcessor.UPDATEDV_KEY_FIELD, URI);
  req.setParam(UpdateDocValuesProcessor.UPDATEDV_VALUE_FIELD, WEIGHT_DV);
  req.setPath(UPDATE_DOCVALUES);
  return req;
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:8,代码来源:UpdateDocValuesTest.java

示例15: batchOperation

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Override
protected void batchOperation(ConcurrentBiMap<Document, SolrInputDocument> oldBatch) throws SolrServerException, IOException {
  List<String> deletes = oldBatch.keySet().stream()
      .filter(doc -> doc.getOperation() == Document.Operation.DELETE)
      .map(Document::getId)
      .collect(Collectors.toList());
  if (deletes.size() > 0) {
    getSolrClient().deleteById(deletes);
  }
  List<SolrInputDocument> adds = oldBatch.keySet().stream()
      .filter(doc -> doc.getOperation() != Document.Operation.DELETE)
      .map(oldBatch::get)
      .collect(Collectors.toList());
  if (adds.size() > 0) {
    Map<String, String> params = getParams();
    if (params == null) {
      getSolrClient().add(adds);
    } else {
      UpdateRequest req = new UpdateRequest();
      req.add(adds);
      // always true right now, but pattern for addtional global params...
      for (String s : params.keySet()) {
        req.setParam(s, params.get(s));
      }
      getSolrClient().request(req);
    }
  }
  for (Document document : oldBatch.keySet()) {
    putIdInThreadContext(document);
    if (document.getOperation() == Document.Operation.DELETE) {
      log().info(Status.INDEXED.getMarker(), "{} deleted from solr successfully", document.getId());
    } else {
      log().info(Status.INDEXED.getMarker(), "{} sent to solr successfully", document.getId());
    }
  }
}
 
开发者ID:nsoft,项目名称:jesterj,代码行数:37,代码来源:SendToSolrCloudProcessor.java


注:本文中的org.apache.solr.client.solrj.request.UpdateRequest.setParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。