SOLR-1930: remove solr deprecations - add.overwritePending/overwriteCommitted/allowDups

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1052924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-12-26 19:11:38 +00:00
parent 7ae1f29704
commit 36aab2d41c
17 changed files with 94 additions and 260 deletions

View File

@ -69,9 +69,6 @@ public class SolrWriter {
try {
AddUpdateCommand command = new AddUpdateCommand();
command.solrDoc = d;
command.allowDups = false;
command.overwritePending = true;
command.overwriteCommitted = true;
processor.processAdd(command);
} catch (Exception e) {
log.warn("Error creating document : " + d, e);

View File

@ -90,19 +90,8 @@ public class ExtractingDocumentLoader extends ContentStreamLoader {
this.processor = processor;
templateAdd = new AddUpdateCommand();
templateAdd.allowDups = false;
templateAdd.overwriteCommitted = true;
templateAdd.overwritePending = true;
templateAdd.overwrite = params.getBool(UpdateParams.OVERWRITE, true);
if (params.getBool(UpdateParams.OVERWRITE, true)) {
templateAdd.allowDups = false;
templateAdd.overwriteCommitted = true;
templateAdd.overwritePending = true;
} else {
templateAdd.allowDups = true;
templateAdd.overwriteCommitted = false;
templateAdd.overwritePending = false;
}
//this is lightweight
autoDetectParser = new AutoDetectParser(config);
this.factory = factory;

View File

@ -93,25 +93,9 @@ public class BinaryUpdateRequestHandler extends ContentStreamHandlerBase {
private AddUpdateCommand getAddCommand(SolrParams params) {
AddUpdateCommand addCmd = new AddUpdateCommand();
boolean overwrite = true; // the default
Boolean overwritePending = null;
Boolean overwriteCommitted = null;
overwrite = params.getBool(UpdateParams.OVERWRITE, overwrite);
addCmd.overwrite = params.getBool(UpdateParams.OVERWRITE, true);
addCmd.commitWithin = params.getInt(COMMIT_WITHIN, -1);
// check if these flags are set
if (overwritePending != null && overwriteCommitted != null) {
if (overwritePending != overwriteCommitted) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"can't have different values for 'overwritePending' and 'overwriteCommitted'");
}
overwrite = overwritePending;
}
addCmd.overwriteCommitted = overwrite;
addCmd.overwritePending = overwrite;
addCmd.allowDups = !overwrite;
return addCmd;
}

View File

@ -186,19 +186,7 @@ abstract class CSVLoader extends ContentStreamLoader {
schema = req.getSchema();
templateAdd = new AddUpdateCommand();
templateAdd.allowDups=false;
templateAdd.overwriteCommitted=true;
templateAdd.overwritePending=true;
if (params.getBool(OVERWRITE,true)) {
templateAdd.allowDups=false;
templateAdd.overwriteCommitted=true;
templateAdd.overwritePending=true;
} else {
templateAdd.allowDups=true;
templateAdd.overwriteCommitted=false;
templateAdd.overwritePending=false;
}
templateAdd.overwrite=params.getBool(OVERWRITE,true);
strategy = new CSVStrategy(',', '"', CSVStrategy.COMMENTS_DISABLED, CSVStrategy.ESCAPE_DISABLED, false, false, false, true);
String sep = params.get(SEPARATOR);

View File

@ -215,7 +215,6 @@ class JsonLoader extends ContentStreamLoader {
{
assertNextEvent( js, JSONParser.OBJECT_START );
AddUpdateCommand cmd = new AddUpdateCommand();
cmd.allowDups = false;
float boost = 1.0f;
while( true ) {
@ -231,7 +230,7 @@ class JsonLoader extends ContentStreamLoader {
cmd.solrDoc = parseDoc( ev, js );
}
else if( XmlUpdateRequestHandler.OVERWRITE.equals( key ) ) {
cmd.allowDups = !js.getBoolean(); // reads next boolean
cmd.overwrite = js.getBoolean(); // reads next boolean
}
else if( XmlUpdateRequestHandler.COMMIT_WITHIN.equals( key ) ) {
cmd.commitWithin = (int)js.getLong();
@ -254,8 +253,6 @@ class JsonLoader extends ContentStreamLoader {
throw new IOException("missing solr document. "+js.getPosition() );
}
cmd.solrDoc.setDocumentBoost( boost );
cmd.overwriteCommitted = !cmd.allowDups;
cmd.overwritePending = !cmd.allowDups;
return cmd;
}
else {

View File

@ -99,39 +99,19 @@ class XMLLoader extends ContentStreamLoader {
XmlUpdateRequestHandler.log.trace("SolrCore.update(add)");
addCmd = new AddUpdateCommand();
boolean overwrite = true; // the default
Boolean overwritePending = null;
Boolean overwriteCommitted = null;
for (int i = 0; i < parser.getAttributeCount(); i++) {
String attrName = parser.getAttributeLocalName(i);
String attrVal = parser.getAttributeValue(i);
if (XmlUpdateRequestHandler.OVERWRITE.equals(attrName)) {
overwrite = StrUtils.parseBoolean(attrVal);
} else if (XmlUpdateRequestHandler.ALLOW_DUPS.equals(attrName)) {
overwrite = !StrUtils.parseBoolean(attrVal);
addCmd.overwrite = StrUtils.parseBoolean(attrVal);
} else if (XmlUpdateRequestHandler.COMMIT_WITHIN.equals(attrName)) {
addCmd.commitWithin = Integer.parseInt(attrVal);
} else if (XmlUpdateRequestHandler.OVERWRITE_PENDING.equals(attrName)) {
overwritePending = StrUtils.parseBoolean(attrVal);
} else if (XmlUpdateRequestHandler.OVERWRITE_COMMITTED.equals(attrName)) {
overwriteCommitted = StrUtils.parseBoolean(attrVal);
} else {
XmlUpdateRequestHandler.log.warn("Unknown attribute id in add:" + attrName);
}
}
// check if these flags are set
if (overwritePending != null && overwriteCommitted != null) {
if (overwritePending != overwriteCommitted) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"can't have different values for 'overwritePending' and 'overwriteCommitted'");
}
overwrite = overwritePending;
}
addCmd.overwriteCommitted = overwrite;
addCmd.overwritePending = overwrite;
addCmd.allowDups = !overwrite;
} else if ("doc".equals(currTag)) {
XmlUpdateRequestHandler.log.trace("adding doc...");
addCmd.clear();

View File

@ -57,24 +57,7 @@ public class XmlUpdateRequestHandler extends ContentStreamHandlerBase {
public static final String OVERWRITE = "overwrite";
public static final String COMMIT_WITHIN = "commitWithin";
/**
* @deprecated use {@link #OVERWRITE}
*/
@Deprecated
public static final String OVERWRITE_COMMITTED = "overwriteCommitted";
/**
* @deprecated use {@link #OVERWRITE}
*/
@Deprecated
public static final String OVERWRITE_PENDING = "overwritePending";
/**
* @deprecated use {@link #OVERWRITE}
*/
@Deprecated
public static final String ALLOW_DUPS = "allowDups";
XMLInputFactory inputFactory;

View File

@ -40,9 +40,7 @@ public class AddUpdateCommand extends UpdateCommand {
// to index.
public SolrInputDocument solrDoc;
public boolean allowDups;
public boolean overwritePending;
public boolean overwriteCommitted;
public boolean overwrite = true;
public Term updateTerm;
public int commitWithin = -1;
@ -114,9 +112,7 @@ public class AddUpdateCommand extends UpdateCommand {
StringBuilder sb = new StringBuilder(commandName);
sb.append(':');
if (indexedId !=null) sb.append("id=").append(indexedId);
sb.append(",allowDups=").append(allowDups);
sb.append(",overwritePending=").append(overwritePending);
sb.append(",overwriteCommitted=").append(overwriteCommitted);
if (!overwrite) sb.append(",overwrite=").append(overwrite);
return sb.toString();
}
}

View File

@ -53,74 +53,7 @@ import org.apache.solr.core.SolrCore;
/**
* <code>DirectUpdateHandler2</code> implements an UpdateHandler where documents are added
* directly to the main Lucene index as opposed to adding to a separate smaller index.
* For this reason, not all combinations to/from pending and committed are supported.
* This version supports efficient removal of duplicates on a commit. It works by maintaining
* a related count for every document being added or deleted. At commit time, for every id with a count,
* all but the last "count" docs with that id are deleted.
* <p>
*
* Supported add command parameters:
<TABLE BORDER>
<TR>
<TH>allowDups</TH>
<TH>overwritePending</TH>
<TH>overwriteCommitted</TH>
<TH>efficiency</TH>
</TR>
<TR>
<TD>false</TD>
<TD>false</TD>
<TD>true</TD>
<TD>fast</TD>
</TR>
<TR>
<TD>true or false</TD>
<TD>true</TD>
<TD>true</TD>
<TD>fast</TD>
</TR>
<TR>
<TD>true</TD>
<TD>false</TD>
<TD>false</TD>
<TD>fastest</TD>
</TR>
</TABLE>
<p>Supported delete commands:
<TABLE BORDER>
<TR>
<TH>command</TH>
<TH>fromPending</TH>
<TH>fromCommitted</TH>
<TH>efficiency</TH>
</TR>
<TR>
<TD>delete</TD>
<TD>true</TD>
<TD>true</TD>
<TD>fast</TD>
</TR>
<TR>
<TD>deleteByQuery</TD>
<TD>true</TD>
<TD>true</TD>
<TD>very slow*</TD>
</TR>
</TABLE>
<p>* deleteByQuery causes a commit to happen (close current index writer, open new index reader)
before it can be processed. If deleteByQuery functionality is needed, it's best if they can
be batched and executed together so they may share the same index reader.
*
* @version $Id$
* @since solr 0.9
*/
public class DirectUpdateHandler2 extends UpdateHandler {
// stats
@ -201,11 +134,9 @@ public class DirectUpdateHandler2 extends UpdateHandler {
addCommandsCumulative.incrementAndGet();
int rc=-1;
// if there is no ID field, use allowDups
// if there is no ID field, don't overwrite
if( idField == null ) {
cmd.allowDups = true;
cmd.overwriteCommitted = false;
cmd.overwritePending = false;
cmd.overwrite = false;
}
iwAccess.lock();
@ -225,7 +156,7 @@ public class DirectUpdateHandler2 extends UpdateHandler {
// should account for most of the time
Term updateTerm = null;
if (cmd.overwriteCommitted || cmd.overwritePending) {
if (cmd.overwrite) {
if (cmd.indexedId == null) {
cmd.indexedId = getIndexedId(cmd.doc);
}

View File

@ -162,7 +162,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
,"//*[@numFound='0']"
);
// test allowDups default of false
// test overwrite default of true
assertU(adoc("id", "42", "val_s", "AAA"));
assertU(adoc("id", "42", "val_s", "BBB"));
@ -181,12 +181,12 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
// test deletes
String [] adds = new String[] {
add( doc("id","101"), "allowDups", "false" ),
add( doc("id","101"), "allowDups", "false" ),
add( doc("id","105"), "allowDups", "true" ),
add( doc("id","102"), "allowDups", "false" ),
add( doc("id","103"), "allowDups", "true" ),
add( doc("id","101"), "allowDups", "false" ),
add( doc("id","101"), "overwrite", "true" ),
add( doc("id","101"), "overwrite", "true" ),
add( doc("id","105"), "overwrite", "false" ),
add( doc("id","102"), "overwrite", "true" ),
add( doc("id","103"), "overwrite", "false" ),
add( doc("id","101"), "overwrite", "true" ),
};
for (String a : adds) {
assertU(a, a);

View File

@ -95,12 +95,12 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test deletes
assertU("<delete><query>id:[100 TO 110]</query></delete>");
assertU("<add allowDups=\"false\"><doc><field name=\"id\">101</field></doc></add>");
assertU("<add allowDups=\"false\"><doc><field name=\"id\">101</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">105</field></doc></add>");
assertU("<add allowDups=\"false\"><doc><field name=\"id\">102</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">103</field></doc></add>");
assertU("<add allowDups=\"false\"><doc><field name=\"id\">101</field></doc></add>");
assertU("<add overwrite=\"true\"><doc><field name=\"id\">101</field></doc></add>");
assertU("<add overwrite=\"true\"><doc><field name=\"id\">101</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">105</field></doc></add>");
assertU("<add overwrite=\"true\"><doc><field name=\"id\">102</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">103</field></doc></add>");
assertU("<add overwrite=\"true\"><doc><field name=\"id\">101</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:[100 TO 110]")
,"//*[@numFound='4']"
@ -124,9 +124,9 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test range
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">apple</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">banana</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">pear</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"val_s\">apple</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"val_s\">banana</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"val_s\">pear</field></doc></add>");
assertU("<commit/>");
assertQ(req("val_s:[a TO z]")
,"//*[@numFound='3'] "
@ -318,7 +318,7 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// check for docs that appear more than once in a range
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">apple</field><field name=\"val_s\">banana</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"val_s\">apple</field><field name=\"val_s\">banana</field></doc></add>");
assertU("<commit/>");
assertQ(req("val_s:[* TO *] OR val_s:[* TO *]")
,"//*[@numFound='4']"
@ -333,7 +333,7 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// <delete><id>44</id></delete>
assertU("<add overwritePending=\"true\" overwriteCommitted=\"true\"><doc><field name=\"id\">44</field><field name=\"text\">red riding hood</field></doc></add>");
assertU("<add><doc><field name=\"id\">44</field><field name=\"text\">red riding hood</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44 AND red")
,"//@numFound[.='1'] "
@ -349,8 +349,8 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// allow duplicates
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\" overwriteCommitted=\"false\" overwritePending=\"false\"><doc><field name=\"id\">44</field><field name=\"text\">red riding hood</field></doc></add>");
assertU("<add allowDups=\"true\" overwriteCommitted=\"false\" overwritePending=\"false\"><doc><field name=\"id\">44</field><field name=\"text\">big bad wolf</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"text\">red riding hood</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"text\">big bad wolf</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"//@numFound[.='2']"
@ -510,16 +510,16 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test integer ranges and sorting
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">1234567890</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">10</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">15</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">-987654321</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">2147483647</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">-2147483648</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">0</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">1234567890</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">10</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">2</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">15</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">-1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">-987654321</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">2147483647</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">-2147483648</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_i\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"*[count(//doc)=10]"
@ -553,16 +553,16 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test long ranges and sorting
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">1234567890</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">10</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">15</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">-987654321</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">9223372036854775807</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">-9223372036854775808</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">0</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">1234567890</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">10</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">2</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">15</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">-1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">-987654321</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">9223372036854775807</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">-9223372036854775808</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_l\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"*[count(//doc)=10]"
@ -596,16 +596,16 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test binary float ranges and sorting
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">1.4142135</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">NaN</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-987654321</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-999999.99</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-1e20</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">0</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">1.4142135</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">Infinity</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-Infinity</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">NaN</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">2</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-987654321</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-999999.99</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-1e20</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sf\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"*[count(//doc)=10]"
@ -645,16 +645,16 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test binary double ranges and sorting
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">1.4142135</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">NaN</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">1e-100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-999999.99</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-1e100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">0</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">1.4142135</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">Infinity</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-Infinity</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">NaN</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">2</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">1e-100</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-999999.99</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-1e100</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"num_sd\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"*[count(//doc)=10]"
@ -696,12 +696,12 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test sorting on multiple fields
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">10</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">1</field><field name=\"b_i\">100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">15</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">1</field><field name=\"b_i\">50</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">0</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"a_i\">10</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"a_i\">1</field><field name=\"b_i\">100</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"a_i\">-1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"a_i\">15</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"a_i\">1</field><field name=\"b_i\">50</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id\">44</field><field name=\"a_i\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"*[count(//doc)=6]"
@ -739,13 +739,13 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test sorting with some docs missing the sort field
assertU("<delete><query>id_i:[1000 TO 1010]</query></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1000</field><field name=\"a_i\">1</field><field name=\"nullfirst\">Z</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1001</field><field name=\"a_i\">10</field><field name=\"nullfirst\">A</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1002</field><field name=\"a_i\">1</field><field name=\"b_si\">100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1003</field><field name=\"a_i\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1004</field><field name=\"a_i\">15</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1005</field><field name=\"a_i\">1</field><field name=\"b_si\">50</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1006</field><field name=\"a_i\">0</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id_i\">1000</field><field name=\"a_i\">1</field><field name=\"nullfirst\">Z</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id_i\">1001</field><field name=\"a_i\">10</field><field name=\"nullfirst\">A</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id_i\">1002</field><field name=\"a_i\">1</field><field name=\"b_si\">100</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id_i\">1003</field><field name=\"a_i\">-1</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id_i\">1004</field><field name=\"a_i\">15</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id_i\">1005</field><field name=\"a_i\">1</field><field name=\"b_si\">50</field></doc></add>");
assertU("<add overwrite=\"false\"><doc><field name=\"id_i\">1006</field><field name=\"a_i\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id_i:[1000 TO 1010]")
,"*[count(//doc)=7]"

View File

@ -76,10 +76,10 @@ public class SampleTest extends SolrTestCaseJ4 {
assertU("less common case, a complex addition with options",
add(doc("id", "4059",
"subject", "Who Me?"),
"allowDups", "true"));
"overwrite", "false"));
assertU("or just make the raw XML yourself",
"<add allowDups=\"true\">" +
"<add overwrite=\"false\">" +
doc("id", "4059",
"subject", "Who Me Again?") + "</add>");

View File

@ -72,7 +72,7 @@ public class BasicZkTest extends AbstractZkTestCase {
assertU(commit());
assertQ(req("id:42"), "//*[@numFound='0']");
// test allowDups default of false
// test overwrite default of true
assertU(adoc("id", "42", "val_s", "AAA"));
assertU(adoc("id", "42", "val_s", "BBB"));
@ -84,12 +84,12 @@ public class BasicZkTest extends AbstractZkTestCase {
assertQ(req("id:42"), "//*[@numFound='1']", "//str[.='DDD']");
// test deletes
String[] adds = new String[] { add(doc("id", "101"), "allowDups", "false"),
add(doc("id", "101"), "allowDups", "false"),
add(doc("id", "105"), "allowDups", "true"),
add(doc("id", "102"), "allowDups", "false"),
add(doc("id", "103"), "allowDups", "true"),
add(doc("id", "101"), "allowDups", "false"), };
String[] adds = new String[] { add(doc("id", "101"), "overwrite", "true"),
add(doc("id", "101"), "overwrite", "true"),
add(doc("id", "105"), "overwrite", "false"),
add(doc("id", "102"), "overwrite", "true"),
add(doc("id", "103"), "overwrite", "false"),
add(doc("id", "101"), "overwrite", "true"), };
for (String a : adds) {
assertU(a, a);
}

View File

@ -94,7 +94,7 @@ public class JsonLoaderTest extends LuceneTestCase {
f = d.getField( "f1" );
assertEquals(2, f.getValues().size());
assertEquals(3.45f, d.getDocumentBoost());
assertEquals(true, add.allowDups);
assertEquals(false, add.overwrite);
// parse the commit commands

View File

@ -46,9 +46,7 @@ public class DirectUpdateHandlerOptimizeTest extends AbstractSolrTestCase {
UpdateHandler updater = core.getUpdateHandler();
AddUpdateCommand cmd = new AddUpdateCommand();
cmd.overwriteCommitted = true;
cmd.overwritePending = true;
cmd.allowDups = false;
//add just under the merge factor, so no segments are merged
//the merge factor is 100 and the maxBufferedDocs is 2, so there should be 50 segments
for (int i = 0; i < 99; i++) {

View File

@ -64,9 +64,6 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
UpdateHandler updater = core.getUpdateHandler();
AddUpdateCommand cmd = new AddUpdateCommand();
cmd.overwriteCommitted = true;
cmd.overwritePending = true;
cmd.allowDups = false;
// Add a valid document
cmd.doc = new Document();
@ -336,9 +333,6 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
UpdateHandler updater = core.getUpdateHandler();
AddUpdateCommand cmd = new AddUpdateCommand();
cmd.overwriteCommitted = true;
cmd.overwritePending = true;
cmd.allowDups = false;
// Add a document
cmd.doc = new Document();

View File

@ -88,9 +88,6 @@ public class TestIndexingPerformance extends AbstractSolrTestCase {
long start = System.currentTimeMillis();
AddUpdateCommand add = new AddUpdateCommand();
add.allowDups = !overwrite;
add.overwriteCommitted = overwrite;
add.overwritePending = overwrite;
Field idField=null;