本文整理汇总了Java中org.apache.solr.update.AddUpdateCommand类的典型用法代码示例。如果您正苦于以下问题:Java AddUpdateCommand类的具体用法?Java AddUpdateCommand怎么用?Java AddUpdateCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AddUpdateCommand类属于org.apache.solr.update包,在下文中一共展示了AddUpdateCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ExtractingDocumentLoader
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
public ExtractingDocumentLoader(SolrQueryRequest req, UpdateRequestProcessor processor,
TikaConfig config, SolrContentHandlerFactory factory) {
this.params = req.getParams();
this.core = req.getCore();
this.config = config;
this.processor = processor;
templateAdd = new AddUpdateCommand(req);
templateAdd.overwrite = params.getBool(UpdateParams.OVERWRITE, true);
templateAdd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1);
//this is lightweight
autoDetectParser = new AutoDetectParser(config);
this.factory = factory;
ignoreTikaException = params.getBool(ExtractingParams.IGNORE_TIKA_EXCEPTION, false);
}
示例2: testCommitWithin
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Test
public void testCommitWithin() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
SolrQueryRequest req = req("literal.id", "one",
ExtractingParams.RESOURCE_NAME, "extraction/version_control.txt",
"commitWithin", "200"
);
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
ExtractingDocumentLoader loader = (ExtractingDocumentLoader) handler.newLoader(req, p);
loader.load(req, rsp, new ContentStreamBase.FileStream(getFile("extraction/version_control.txt")),p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(200, add.commitWithin);
req.close();
}
示例3: processAdd
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
final SolrInputDocument doc = cmd.getSolrInputDocument();
final String math = doc.containsKey(ttlField)
? doc.getFieldValue(ttlField).toString() : defaultTtl;
if (null != math) {
try {
final DateMathParser dmp = new DateMathParser();
// TODO: should we try to accept things like "1DAY" as well as "+1DAY" ?
// How?
// 'startsWith("+")' is a bad idea because it would cause porblems with
// things like "/DAY+1YEAR"
// Maybe catch ParseException and rety with "+" prepended?
doc.addField(expireField, dmp.parseMath(math));
} catch (ParseException pe) {
throw new SolrException(BAD_REQUEST, "Can't parse ttl as date math: " + math, pe);
}
}
super.processAdd(cmd);
}
示例4: isLeader
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
boolean isLeader(UpdateCommand cmd) {
updateCommand = cmd;
if (zkEnabled) {
zkCheck();
if (cmd instanceof AddUpdateCommand) {
AddUpdateCommand acmd = (AddUpdateCommand)cmd;
nodes = setupRequest(acmd.getHashableId(), acmd.getSolrInputDocument());
} else if (cmd instanceof DeleteUpdateCommand) {
DeleteUpdateCommand dcmd = (DeleteUpdateCommand)cmd;
nodes = setupRequest(dcmd.getId(), null);
}
} else {
isLeader = getNonZkLeaderAssumption(req);
}
return isLeader;
}
示例5: processAdd
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }
// call delegate first so we can log things like the version that get set later
if (next != null) next.processAdd(cmd);
// Add a list of added id's to the response
if (adds == null) {
adds = new ArrayList<>();
toLog.add("add",adds);
}
if (adds.size() < maxNumToLog) {
long version = cmd.getVersion();
String msg = cmd.getPrintableId();
if (version != 0) msg = msg + " (" + version + ')';
adds.add(msg);
}
numAdds++;
}
示例6: processBoost
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
public void processBoost(AddUpdateCommand command) {
SolrInputDocument document = command.getSolrInputDocument();
if (document.containsKey(inputFieldname)) {
String value = (String) document.getFieldValue(inputFieldname);
double boost = 1.0f;
for (BoostEntry boostEntry : boostEntries) {
if (boostEntry.getPattern().matcher(value).matches()) {
if (log.isDebugEnabled()) {
log.debug("Pattern match " + boostEntry.getPattern().pattern() + " for " + value);
}
boost = (boostEntry.getBoost() * 1000) * (boost * 1000) / 1000000;
}
}
document.setField(boostFieldname, boost);
if (log.isDebugEnabled()) {
log.debug("Value " + boost + ", applied to field " + boostFieldname);
}
}
}
示例7: handleStreamingSingleDocs
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
private void handleStreamingSingleDocs() throws IOException
{
while( true ) {
int ev = parser.nextEvent();
if(ev == JSONParser.EOF) return;
if(ev == JSONParser.OBJECT_START) {
assertEvent(ev, JSONParser.OBJECT_START);
AddUpdateCommand cmd = new AddUpdateCommand(req);
cmd.commitWithin = commitWithin;
cmd.overwrite = overwrite;
cmd.solrDoc = parseDoc(ev);
processor.processAdd(cmd);
} else if(ev == JSONParser.ARRAY_START){
handleAdds();
} else{
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unexpected event :"+ev);
}
}
}
示例8: testCommitWithin
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Test
public void testCommitWithin() throws Exception {
String csvString = "id;name\n123;hello";
SolrQueryRequest req = req("separator", ";",
"commitWithin", "200");
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
CSVLoader loader = new CSVLoader();
loader.load(req, rsp, new ContentStreamBase.StringStream.StringStream(csvString), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(200, add.commitWithin);
req.close();
}
示例9: testRequestParams
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Test
public void testRequestParams() throws Exception
{
String xml =
"<add>" +
" <doc>" +
" <field name=\"id\">12345</field>" +
" <field name=\"name\">kitten</field>" +
" </doc>" +
"</add>";
SolrQueryRequest req = req("commitWithin","100","overwrite","false");
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
XMLLoader loader = new XMLLoader().init(null);
loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(100, add.commitWithin);
assertEquals(false, add.overwrite);
req.close();
}
示例10: testExternalEntities
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Test
public void testExternalEntities() throws Exception
{
String file = getFile("mailing_lists.pdf").toURI().toASCIIString();
String xml =
"<?xml version=\"1.0\"?>" +
// check that external entities are not resolved!
"<!DOCTYPE foo [<!ENTITY bar SYSTEM \""+file+"\">]>" +
"<add>" +
" &bar;" +
" <doc>" +
" <field name=\"id\">12345</field>" +
" <field name=\"name\">kitten</field>" +
" </doc>" +
"</add>";
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
XMLLoader loader = new XMLLoader().init(null);
loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals("12345", add.solrDoc.getField("id").getFirstValue());
req.close();
}
示例11: testExtendedFieldValues
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
public void testExtendedFieldValues() throws Exception {
String str = "[{'id':'1', 'val_s':{'add':'foo'}}]".replace('\'', '"');
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
JsonLoader loader = new JsonLoader();
loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
assertEquals( 1, p.addCommands.size() );
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(add.commitWithin, -1);
assertEquals(add.overwrite, true);
SolrInputDocument d = add.solrDoc;
SolrInputField f = d.getField( "id" );
assertEquals("1", f.getValue());
f = d.getField( "val_s" );
Map<String,Object> map = (Map<String,Object>)f.getValue();
assertEquals("foo",map.get("add"));
req.close();
}
示例12: testBooleanValuesInAdd
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Test
public void testBooleanValuesInAdd() throws Exception {
String str = "{'add':[{'id':'1','b1':true,'b2':false,'b3':[false,true]}]}".replace('\'', '"');
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
JsonLoader loader = new JsonLoader();
loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
assertEquals(1, p.addCommands.size());
AddUpdateCommand add = p.addCommands.get(0);
SolrInputDocument d = add.solrDoc;
SolrInputField f = d.getField("b1");
assertEquals(Boolean.TRUE, f.getValue());
f = d.getField("b2");
assertEquals(Boolean.FALSE, f.getValue());
f = d.getField("b3");
assertEquals(2, ((List)f.getValue()).size());
assertEquals(Boolean.FALSE, ((List)f.getValue()).get(0));
assertEquals(Boolean.TRUE, ((List)f.getValue()).get(1));
req.close();
}
示例13: testIntegerValuesInAdd
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Test
public void testIntegerValuesInAdd() throws Exception {
String str = "{'add':[{'id':'1','i1':256,'i2':-5123456789,'i3':[0,1]}]}".replace('\'', '"');
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
JsonLoader loader = new JsonLoader();
loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
assertEquals(1, p.addCommands.size());
AddUpdateCommand add = p.addCommands.get(0);
SolrInputDocument d = add.solrDoc;
SolrInputField f = d.getField("i1");
assertEquals(256L, f.getValue());
f = d.getField("i2");
assertEquals(-5123456789L, f.getValue());
f = d.getField("i3");
assertEquals(2, ((List)f.getValue()).size());
assertEquals(0L, ((List)f.getValue()).get(0));
assertEquals(1L, ((List)f.getValue()).get(1));
req.close();
}
示例14: testDecimalValuesInAdd
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
@Test
public void testDecimalValuesInAdd() throws Exception {
String str = "{'add':[{'id':'1','d1':256.78,'d2':-5123456789.0,'d3':0.0,'d3':1.0,'d4':1.7E-10}]}".replace('\'', '"');
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
JsonLoader loader = new JsonLoader();
loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
assertEquals(1, p.addCommands.size());
AddUpdateCommand add = p.addCommands.get(0);
SolrInputDocument d = add.solrDoc;
SolrInputField f = d.getField("d1");
assertEquals(256.78, f.getValue());
f = d.getField("d2");
assertEquals(-5123456789.0, f.getValue());
f = d.getField("d3");
assertEquals(2, ((List)f.getValue()).size());
assertTrue(((List)f.getValue()).contains(0.0));
assertTrue(((List) f.getValue()).contains(1.0));
f = d.getField("d4");
assertEquals(1.7E-10, f.getValue());
req.close();
}
示例15: addNode
import org.apache.solr.update.AddUpdateCommand; //导入依赖的package包/类
private NodeRef addNode(SolrCore core, AlfrescoSolrDataModel dataModel, int txid, int dbid, int aclid, QName type,
QName[] aspects, Map<QName, PropertyValue> properties, Map<QName, String> content, String owner,
ChildAssociationRef[] parentAssocs, NodeRef[] ancestors, String[] paths, NodeRef nodeRef, boolean commit)
throws IOException
{
AddUpdateCommand addDocCmd = new AddUpdateCommand(solrQueryRequest);
addDocCmd.overwrite = true;
addDocCmd.solrDoc = createDocument(dataModel, new Long(txid), new Long(dbid), nodeRef, type, aspects,
properties, content, new Long(aclid), paths, owner, parentAssocs, ancestors);
core.getUpdateHandler().addDoc(addDocCmd);
if (commit)
{
core.getUpdateHandler().commit(new CommitUpdateCommand(solrQueryRequest, false));
}
return nodeRef;
}