本文整理汇总了Java中org.apache.solr.client.solrj.impl.HttpSolrServer.setRequestWriter方法的典型用法代码示例。如果您正苦于以下问题:Java HttpSolrServer.setRequestWriter方法的具体用法?Java HttpSolrServer.setRequestWriter怎么用?Java HttpSolrServer.setRequestWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.impl.HttpSolrServer
的用法示例。
在下文中一共展示了HttpSolrServer.setRequestWriter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNewHttpSolrServer
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
/**
*
* @param indexUrl
* @return
*/
public static HttpSolrServer getNewHttpSolrServer(String indexUrl) {
if (indexUrl == null) {
throw new IllegalArgumentException("indexUrl may not be null");
}
HttpSolrServer server = new HttpSolrServer(indexUrl);
server.setSoTimeout(TIMEOUT_SO); // socket read timeout
server.setConnectionTimeout(TIMEOUT_CONNECTION);
server.setDefaultMaxConnectionsPerHost(100);
server.setMaxTotalConnections(100);
server.setFollowRedirects(false); // defaults to false
server.setAllowCompression(true);
server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
// server.setParser(new XMLResponseParser()); // binary parser is used by default
server.setRequestWriter(new BinaryRequestWriter());
return server;
}
示例2: createNewSolrServer
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public SolrServer createNewSolrServer()
{
try {
// setup the server...
String url = jetty.getBaseUrl().toString() + "/collection1";
HttpSolrServer s = new HttpSolrServer( url );
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
s.setDefaultMaxConnectionsPerHost(100);
s.setMaxTotalConnections(100);
s.setUseMultiPartPost(random().nextBoolean());
// where the magic happens
s.setParser(new BinaryResponseParser());
s.setRequestWriter(new BinaryRequestWriter());
return s;
}
catch( Exception ex ) {
throw new RuntimeException( ex );
}
}
示例3: createNewSolrServer
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public SolrServer createNewSolrServer() {
try {
// setup the server...
String url = jetty.getBaseUrl().toString() + "/collection1";
HttpSolrServer s = new HttpSolrServer(url);
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
s.setDefaultMaxConnectionsPerHost(100);
s.setMaxTotalConnections(100);
s.setUseMultiPartPost(random().nextBoolean());
if (random().nextBoolean()) {
s.setParser(new BinaryResponseParser());
s.setRequestWriter(new BinaryRequestWriter());
}
return s;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例4: createNewSolrServer
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public SolrServer createNewSolrServer() {
try {
String url = jetty.getBaseUrl().toString() + "/collection1";
HttpSolrServer s = new HttpSolrServer(url);
s.setUseMultiPartPost(random().nextBoolean());
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
s.setDefaultMaxConnectionsPerHost(100);
s.setMaxTotalConnections(100);
s.setParser(new XMLResponseParser());
s.setRequestWriter(new RequestWriter());
return s;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例5: getNewHttpSolrServer
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public static HttpSolrServer getNewHttpSolrServer(String confFilename) throws FatalIndexerException {
HttpSolrServer server = new HttpSolrServer(Configuration.getInstance(confFilename).getConfiguration("solrUrl"));
server.setSoTimeout(TIMEOUT_SO); // socket read timeout
server.setConnectionTimeout(TIMEOUT_CONNECTION);
server.setDefaultMaxConnectionsPerHost(100);
server.setMaxTotalConnections(100);
server.setFollowRedirects(false); // defaults to false
server.setAllowCompression(true);
server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
// server.setParser(new XMLResponseParser()); // binary parser is used by default
server.setRequestWriter(new BinaryRequestWriter());
return server;
}
示例6: 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);
}
示例7: 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);
}
示例8: 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());
}