本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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());
}
示例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());
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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;
}
示例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());
}
}
}