SOLR-1038 -- Remove the automatic commit from the API

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@760113 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-03-30 19:19:17 +00:00
parent 8d05c79dc3
commit 8c1725beee
2 changed files with 6 additions and 17 deletions

View File

@ -600,24 +600,16 @@ public class CommonsHttpSolrServer extends SolrServer
}
/**
* Adds the documents supplied by the given iterator. A commit is called after all the documents are added.
* If an exception is thrown, commit is not called.
* Adds the documents supplied by the given iterator.
*
* @param docIterator the iterator which returns SolrInputDocument instances
* @param commitParams additional parameters such as optimize, waitFlush, waitSearcher
*
* @return the response from the SolrServer
*/
public UpdateResponse addAndCommit(Iterator<SolrInputDocument> docIterator, SolrParams commitParams)
public UpdateResponse add(Iterator<SolrInputDocument> docIterator)
throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
req.setDocIterator(docIterator);
if (commitParams instanceof ModifiableSolrParams) {
req.setParams((ModifiableSolrParams) commitParams);
} else if (commitParams != null) {
req.setParams(new ModifiableSolrParams(commitParams));
}
req.setParam(UpdateParams.COMMIT, "true");
req.setDocIterator(docIterator);
return req.process(this);
}
}

View File

@ -58,7 +58,7 @@ public class TestBatchUpdate extends SolrExampleTestBase {
private void doIt(CommonsHttpSolrServer commonsHttpSolrServer) throws SolrServerException, IOException {
final int[] counter = new int[1];
counter[0] = 0;
commonsHttpSolrServer.addAndCommit(new Iterator<SolrInputDocument>() {
commonsHttpSolrServer.add(new Iterator<SolrInputDocument>() {
public boolean hasNext() {
return counter[0] < numdocs;
@ -75,16 +75,14 @@ public class TestBatchUpdate extends SolrExampleTestBase {
//do nothing
}
}, null);
});
commonsHttpSolrServer.commit();
SolrQuery query = new SolrQuery("*:*");
QueryResponse response = commonsHttpSolrServer.query(query);
assertEquals(0, response.getStatus());
assertEquals(numdocs, response.getResults().getNumFound());
}
@Override public void setUp() throws Exception
{
super.setUp();
@ -102,7 +100,6 @@ public class TestBatchUpdate extends SolrExampleTestBase {
jetty.stop(); // stop the server
}
@Override
protected SolrServer getSolrServer()
{