本文整理汇总了Java中org.apache.solr.client.solrj.impl.BinaryResponseParser类的典型用法代码示例。如果您正苦于以下问题:Java BinaryResponseParser类的具体用法?Java BinaryResponseParser怎么用?Java BinaryResponseParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BinaryResponseParser类属于org.apache.solr.client.solrj.impl包,在下文中一共展示了BinaryResponseParser类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createNewSolrServer
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的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 );
}
}
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:SolrExampleBinaryTest.java
示例2: createNewSolrServer
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的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);
}
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:SolrSchemalessExampleTests.java
示例3: createNewSolrServer
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
@Override
public SolrServer createNewSolrServer()
{
try {
// setup the server...
String url = jetty.getBaseUrl().toString();
HttpSolrServer s = new HttpSolrServer( url );
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
s.setDefaultMaxConnectionsPerHost(100);
s.setMaxTotalConnections(100);
// where the magic happens
s.setParser(new BinaryResponseParser());
s.setRequestWriter(new BinaryRequestWriter());
return s;
}
catch( Exception ex ) {
throw new RuntimeException( ex );
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:22,代码来源:SolrExampleBinaryTest.java
示例4: createNewSolrServer
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
@Override
public SolrServer createNewSolrServer() {
ConcurrentUpdateSolrServer s = (ConcurrentUpdateSolrServer)super.createNewSolrServer();
s.setParser(new BinaryResponseParser());
s.setRequestWriter(new BinaryRequestWriter());
return s;
}
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:SolrExampleStreamingBinaryTest.java
示例5: testRealtimeGet
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
@Test
public void testRealtimeGet() throws Exception
{
SolrServer server = getSolrServer();
// Empty the database...
server.deleteByQuery( "*:*" );// delete everything!
// Now add something...
SolrInputDocument doc = new SolrInputDocument();
doc.addField( "id", "DOCID", 1.0f );
doc.addField( "name", "hello", 1.0f );
server.add( doc );
server.commit(); // Since the transaction log is disabled in the example, we need to commit
SolrQuery q = new SolrQuery();
q.setRequestHandler("/get");
q.set("id", "DOCID");
q.set("fl", "id,name,aaa:[value v=aaa]");
// First Try with the BinaryResponseParser
QueryRequest req = new QueryRequest( q );
req.setResponseParser(new BinaryResponseParser());
QueryResponse rsp = req.process(server);
SolrDocument out = (SolrDocument)rsp.getResponse().get("doc");
assertEquals("DOCID", out.get("id"));
assertEquals("hello", out.get("name"));
assertEquals("aaa", out.get("aaa"));
// Then with the XMLResponseParser
req.setResponseParser(new XMLResponseParser());
rsp = req.process(server);
out = (SolrDocument)rsp.getResponse().get("doc");
assertEquals("DOCID", out.get("id"));
assertEquals("hello", out.get("name"));
assertEquals("aaa", out.get("aaa"));
}
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:SolrExampleTests.java
示例6: trackRequestResult
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
public void trackRequestResult(HttpResponse resp, boolean success) {
if (rfTracker != null) {
Integer rf = null;
if (resp != null) {
// need to parse out the rf from requests that were forwards to another leader
InputStream inputStream = null;
try {
inputStream = resp.getEntity().getContent();
BinaryResponseParser brp = new BinaryResponseParser();
NamedList<Object> nl= brp.processResponse(inputStream, null);
Object hdr = nl.get("responseHeader");
if (hdr != null && hdr instanceof NamedList) {
NamedList<Object> hdrList = (NamedList<Object>)hdr;
Object rfObj = hdrList.get(UpdateRequest.REPFACT);
if (rfObj != null && rfObj instanceof Integer) {
rf = (Integer)rfObj;
}
}
} catch (Exception e) {
log.warn("Failed to parse response from "+node+" during replication factor accounting due to: "+e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (Exception ignore){}
}
}
}
rfTracker.trackRequestResult(node, success, rf);
}
}
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:SolrCmdDistributor.java
示例7: testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
@Test
public void testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin() throws Exception {
assertU(add(doc("id", "1", "nullfirst", "1")));
assertU(add(doc("id", "2", "nullfirst", "1")));
assertU(add(doc("id", "3", "nullfirst", "2")));
assertU(add(doc("id", "4", "nullfirst", "2")));
assertU(add(doc("id", "5", "nullfirst", "2")));
assertU(add(doc("id", "6", "nullfirst", "3")));
assertU(commit());
SolrQueryRequest request =
req("q", "*:*","group", "true", "group.field", "nullfirst", "group.main", "true", "wt", "javabin", "start", "4", "rows", "10");
SolrQueryResponse response = new SolrQueryResponse();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(request, response));
String handlerName = request.getParams().get(CommonParams.QT);
h.getCore().execute(h.getCore().getRequestHandler(handlerName), request, response);
BinaryResponseWriter responseWriter = new BinaryResponseWriter();
responseWriter.write(out, request, response);
} finally {
request.close();
SolrRequestInfo.clearRequestInfo();
}
assertEquals(6, ((ResultContext) response.getValues().get("response")).docs.matches());
new BinaryResponseParser().processResponse(new ByteArrayInputStream(out.toByteArray()), "");
out.close();
}
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TestGroupingSearch.java
示例8: getParsedResponse
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
/**
* Parse the solr response to named list (need to create solrj query
* respond).
*
* @param req
* The request.
* @param rsp
* The response.
* @return The named list.
*/
public NamedList<Object> getParsedResponse(SolrQueryRequest req, SolrQueryResponse rsp) {
try {
BinaryResponseWriter writer = new BinaryResponseWriter();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
writer.write(bos, req, rsp);
BinaryResponseParser parser = new BinaryResponseParser();
return parser.processResponse(new ByteArrayInputStream(bos.toByteArray()), "UTF-8");
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:22,代码来源:SolrServletEmulator.java
示例9: testUnicode
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
public void testUnicode() throws Exception {
Random random = random();
int numIterations = atLeast(3);
SolrServer server = getSolrServer();
// save the old parser, so we can set it back.
ResponseParser oldParser = null;
if (server instanceof HttpSolrServer) {
HttpSolrServer cserver = (HttpSolrServer) server;
oldParser = cserver.getParser();
}
try {
for (int iteration = 0; iteration < numIterations; iteration++) {
// choose format
if (server instanceof HttpSolrServer) {
if (random.nextBoolean()) {
((HttpSolrServer) server).setParser(new BinaryResponseParser());
} else {
((HttpSolrServer) server).setParser(new XMLResponseParser());
}
}
int numDocs = TestUtil.nextInt(random(), 1, 10 * RANDOM_MULTIPLIER);
// Empty the database...
server.deleteByQuery("*:*");// delete everything!
List<SolrInputDocument> docs = new ArrayList<>();
for (int i = 0; i < numDocs; i++) {
// Now add something...
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "" + i);
doc.addField("unicode_s", randomTestString(30));
docs.add(doc);
}
server.add(docs);
server.commit();
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.setRows(numDocs);
QueryResponse rsp = server.query( query );
for (int i = 0; i < numDocs; i++) {
String expected = (String) docs.get(i).getFieldValue("unicode_s");
String actual = (String) rsp.getResults().get(i).getFieldValue("unicode_s");
assertEquals(expected, actual);
}
}
} finally {
if (oldParser != null) {
// set the old parser back
((HttpSolrServer)server).setParser(oldParser);
}
}
}
开发者ID:europeana,项目名称:search,代码行数:61,代码来源:SolrExampleTests.java
示例10: getContentType
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
@Override
public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {
return BinaryResponseParser.BINARY_CONTENT_TYPE;
}
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:BinaryResponseWriter.java
示例11: testUnicode
import org.apache.solr.client.solrj.impl.BinaryResponseParser; //导入依赖的package包/类
public void testUnicode() throws Exception {
Random random = random();
int numIterations = atLeast(3);
SolrServer server = getSolrServer();
// save the old parser, so we can set it back.
ResponseParser oldParser = null;
if (server instanceof HttpSolrServer) {
HttpSolrServer cserver = (HttpSolrServer) server;
oldParser = cserver.getParser();
}
try {
for (int iteration = 0; iteration < numIterations; iteration++) {
// choose format
if (server instanceof HttpSolrServer) {
if (random.nextBoolean()) {
((HttpSolrServer) server).setParser(new BinaryResponseParser());
} else {
((HttpSolrServer) server).setParser(new XMLResponseParser());
}
}
int numDocs = _TestUtil.nextInt(random(), 1, 10*RANDOM_MULTIPLIER);
// Empty the database...
server.deleteByQuery("*:*");// delete everything!
List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
for (int i = 0; i < numDocs; i++) {
// Now add something...
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "" + i);
doc.addField("unicode_s", randomTestString(30));
docs.add(doc);
}
server.add(docs);
server.commit();
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.setRows(numDocs);
QueryResponse rsp = server.query( query );
for (int i = 0; i < numDocs; i++) {
String expected = (String) docs.get(i).getFieldValue("unicode_s");
String actual = (String) rsp.getResults().get(i).getFieldValue("unicode_s");
assertEquals(expected, actual);
}
}
} finally {
if (oldParser != null) {
// set the old parser back
((HttpSolrServer)server).setParser(oldParser);
}
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:61,代码来源:SolrExampleTests.java
注:本文中的org.apache.solr.client.solrj.impl.BinaryResponseParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论