本文整理匯總了Java中org.apache.solr.client.solrj.impl.HttpSolrServer.deleteByQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpSolrServer.deleteByQuery方法的具體用法?Java HttpSolrServer.deleteByQuery怎麽用?Java HttpSolrServer.deleteByQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.impl.HttpSolrServer
的用法示例。
在下文中一共展示了HttpSolrServer.deleteByQuery方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testArbitraryJsonIndexing
import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Test
public void testArbitraryJsonIndexing() throws Exception {
HttpSolrServer server = (HttpSolrServer) getSolrServer();
server.deleteByQuery("*:*");
server.commit();
assertNumFound("*:*", 0); // make sure it got in
// two docs, one with uniqueKey, another without it
String json = "{\"id\":\"abc1\", \"name\": \"name1\"} {\"name\" : \"name2\"}";
HttpClient httpClient = server.getHttpClient();
HttpPost post = new HttpPost(server.getBaseURL() + "/update/json/docs");
post.setHeader("Content-Type", "application/json");
post.setEntity(new InputStreamEntity(new ByteArrayInputStream(json.getBytes("UTF-8")), -1));
HttpResponse response = httpClient.execute(post);
assertEquals(200, response.getStatusLine().getStatusCode());
server.commit();
assertNumFound("*:*", 2);
}
示例2: clearCollection
import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
void clearCollection( ) throws Exception {
try {
HttpSolrServer client = getSolrClient( );
client.deleteByQuery( collection, "*:*" );
client.commit( collection );
}
catch ( Exception e ) {
System.out.println( "Got Exception! " + e );
}
}
示例3: testWithXml
import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Test
public void testWithXml() throws Exception {
HttpSolrServer httpSolrServer = (HttpSolrServer) getSolrServer();
httpSolrServer.setRequestWriter(new RequestWriter());
httpSolrServer.deleteByQuery( "*:*" ); // delete everything!
doIt(httpSolrServer);
}
示例4: testWithBinary
import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Test
public void testWithBinary()throws Exception{
HttpSolrServer httpSolrServer = (HttpSolrServer) getSolrServer();
httpSolrServer.setRequestWriter(new BinaryRequestWriter());
httpSolrServer.deleteByQuery( "*:*" ); // delete everything!
doIt(httpSolrServer);
}
示例5: testWithBinaryBean
import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Test
public void testWithBinaryBean()throws Exception{
HttpSolrServer httpSolrServer = (HttpSolrServer) getSolrServer();
httpSolrServer.setRequestWriter(new BinaryRequestWriter());
httpSolrServer.deleteByQuery( "*:*" ); // delete everything!
final int[] counter = new int[1];
counter[0] = 0;
httpSolrServer.addBeans(new Iterator<Bean>() {
@Override
public boolean hasNext() {
return counter[0] < numdocs;
}
@Override
public Bean next() {
Bean bean = new Bean();
bean.id = "" + (++counter[0]);
bean.cat = "foocat";
return bean;
}
@Override
public void remove() {
//do nothing
}
});
httpSolrServer.commit();
SolrQuery query = new SolrQuery("*:*");
QueryResponse response = httpSolrServer.query(query);
assertEquals(0, response.getStatus());
assertEquals(numdocs, response.getResults().getNumFound());
}