本文整理汇总了Java中org.apache.solr.client.solrj.request.QueryRequest.process方法的典型用法代码示例。如果您正苦于以下问题:Java QueryRequest.process方法的具体用法?Java QueryRequest.process怎么用?Java QueryRequest.process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.request.QueryRequest
的用法示例。
在下文中一共展示了QueryRequest.process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runQuery
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
/**
* Verwendung des Standard Query Parsers, der nur ein Index durchsucht (standardmäßig soll im Feld fulltext_stemmed
* gesucht werden)
*
* @param queryString Suchanfrage
*/
private void runQuery(String queryString) {
SolrQuery query = new SolrQuery();
query.setQuery(queryString);
// TODO Standardsuchfeld definieren mittels Query-Parameter df
query.set("fl", "*,score"); // Feldliste im Resultat (* bedeutet, dass alle Felder zurückgegeben werden, die als stored="true" markiert sind)
query.setRows(10);
QueryRequest req = new QueryRequest(query);
req.setBasicAuthCredentials(Configuration.USERNAME, Configuration.PASSWORD);
QueryResponse response = null;
try {
response = req.process(solrClient);
} catch (SolrServerException|IOException e) {
// do something reasonable
System.err.println(e);
}
printRanking(response);
}
示例2: testQtUpdateFails
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
/** SOLR-3161
* Technically stream.body isn't remote streaming, but there wasn't a better place for this test method. */
@Test(expected = SolrException.class)
public void testQtUpdateFails() throws SolrServerException {
SolrQuery query = new SolrQuery();
query.setQuery( "*:*" );//for anything
query.add("echoHandler","true");
//sneaky sneaky
query.add("qt","/update");
query.add("stream.body","<delete><query>*:*</query></delete>");
QueryRequest queryRequest = new QueryRequest(query) {
@Override
public String getPath() { //don't let superclass substitute qt for the path
return "/select";
}
};
QueryResponse rsp = queryRequest.process(getSolrServer());
//!! should *fail* above for security purposes
String handler = (String) rsp.getHeader().get("handler");
System.out.println(handler);
}
示例3: executeNativeQuery
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
@Override
public NativeQueryResult executeNativeQuery(Map<String, String[]> parameters) {
SolrParams params = createSolrParams(parameters);
try {
QueryRequest request = new QueryRequest(params, METHOD.POST);
request.setResponseParser(new InputStreamResponseParser("json"));
QueryResponse response = request.process(this.solrClient);
InputStream inputStream = (InputStream) response.getResponse().get("stream");
if (inputStream != null) {
return new SolrNativeQueryResult(inputStream);
}
return new SolrNativeQueryResult(this.serializeResponse(params, response));
} catch (SolrException | SolrServerException | IOException e) {
throw new DataRetrievalException("Could not execute direct query with parameters " + parameters.toString() + ".", e);
}
}
示例4: getIdsResponse
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private QueryResponse getIdsResponse(ExpectedResult expectedResult) throws Exception {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < expectedResult.ids.length; ++i) {
if (i != 0) {
builder.append(",");
}
builder.append(expectedResult.ids[ i ]);
}
ModifiableSolrParams params = new ModifiableSolrParams();
params.add("ids", builder.toString());
if (expectedResult.fl != null) {
params.add("fl", expectedResult.fl);
}
QueryRequest request = getRealTimeGetRequest(params);
return request.process(expectedResult.server);
}
示例5: testTagStreaming
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
@Test
public void testTagStreaming() throws IOException, SolrServerException {
ModifiableSolrParams params = params();
String input = "foo boston bar";//just one tag;
QueryRequest req = new SolrTaggerRequest(params, input);
req.setPath("/tag");
final AtomicReference<SolrDocument> refDoc = new AtomicReference<>();
req.setStreamingResponseCallback(new StreamingResponseCallback() {
@Override
public void streamSolrDocument(SolrDocument doc) {
refDoc.set(doc);
}
@Override
public void streamDocListInfo(long numFound, long start, Float maxScore) {
}
});
QueryResponse rsp = req.process(solrServer);
assertNotNull(rsp.getResponse().get("tags"));
assertNotNull(refDoc.get());
assertEquals("Boston", ((Field)refDoc.get().getFieldValue("name")).stringValue());
}
示例6: runQueryOnMultipleFields
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
/**
* Verwendung des DisMax Query Parsers, um eine feldübergreifende Suche zu ermöglichen
*
* Unterschiedliche Gewichtung der Suchfelder gemäß Aufgabenstellung
*
* Boosting auf Basis der Anzahl der Downloads in den letzten 30 Tagen (Log-gewichtet)
*
* @param queryString Suchanfrage
*/
private void runQueryOnMultipleFields(String queryString) {
SolrQuery query = new SolrQuery();
query.setQuery(queryString);
// TODO DisMax Query Parser verwenden und geeignete Parameter setzen
query.set("defType", "TODO");
query.set("qf", "TODO");
query.set("bf", "TODO");
query.set("fl", "*,score"); // Feldliste im Resultat (* bedeutet, dass alle Felder zurückgegeben werden, die als stored="true" markiert sind)
query.setRows(10);
QueryRequest req = new QueryRequest(query);
req.setBasicAuthCredentials(Configuration.USERNAME, Configuration.PASSWORD);
QueryResponse response = null;
try {
response = req.process(solrClient);
} catch (SolrServerException|IOException e) {
// do something reasonable
System.err.println(e);
}
printRanking(response);
}
示例7: testRealtimeGet
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的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"));
}
示例8: test404ViaHttp
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
public void test404ViaHttp() throws SolrServerException {
SolrServer server = getSolrServer();
QueryRequest request = new QueryRequest(params("file",
"does-not-exist-404.txt"));
request.setPath("/admin/file");
try {
QueryResponse resp = request.process(server);
fail("didn't get 404 exception");
} catch (SolrException e) {
assertEquals(404, e.code());
}
}
示例9: testDirList
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
public void testDirList() throws SolrServerException {
SolrServer server = getSolrServer();
//assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends SolrTestCaseJ4
QueryRequest request = new QueryRequest();
request.setPath("/admin/file");
QueryResponse resp = request.process(server);
assertEquals(0,resp.getStatus());
assertTrue(((NamedList) resp.getResponse().get("files")).size() > 0);//some files
}
示例10: query
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
/**
* Returns the QueryResponse from {@link #queryServer}
*/
protected QueryResponse query(String json, ModifiableSolrParams params) throws Exception
{
params.set("distrib", "false");
QueryRequest request = getAlfrescoRequest(json, params);
QueryResponse controlRsp = request.process(controlClient);
validateControlData(controlRsp);
params.remove("distrib");
setDistributedParams(params);
QueryResponse rsp = queryServer(json, params);
compareResponses(rsp, controlRsp);
return rsp;
}
示例11: queryServer
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
protected QueryResponse queryServer(String json, SolrParams params) throws SolrServerException
{
// query a random server
int which = r.nextInt(clients.size());
SolrServer client = clients.get(which);
QueryRequest request = getAlfrescoRequest(json, params);
return request.process(client);
}
示例12: checkDeleteByQuery
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private void checkDeleteByQuery(QueryRequest query, CloudSolrServer server,
String queryUser, int expectedQueryDocs) throws Exception {
QueryResponse rsp = query.process(server);
long junitResults = rsp.getResults().getNumFound();
assertEquals(0, junitResults);
setAuthenticationUser(queryUser);
rsp = query.process(server);
long docLevelResults = rsp.getResults().getNumFound();
assertEquals(expectedQueryDocs, docLevelResults);
}
示例13: checkDeleteById
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private void checkDeleteById(QueryRequest request, CloudSolrServer server)
throws Exception {
QueryResponse rsp = request.process(server);
long junitResults = rsp.getResults().getNumFound();
assertEquals(0, junitResults);
setAuthenticationUser("docLevel");
rsp = request.process(server);
long docLevelResults = rsp.getResults().getNumFound();
assertEquals(0, docLevelResults);
}
示例14: getIdResponse
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private QueryResponse getIdResponse(ExpectedResult expectedResult) throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
for (int i = 0; i < expectedResult.ids.length; ++i) {
params.add("id", expectedResult.ids[ i ]);
}
if (expectedResult.fl != null) {
params.add("fl", expectedResult.fl);
}
QueryRequest request = getRealTimeGetRequest(params);
return request.process(expectedResult.server);
}
示例15: testTag
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
@Test
public void testTag() throws SolrServerException, IOException {
ModifiableSolrParams params = params();
String input = "foo boston bar";//just one tag;
QueryRequest req = new SolrTaggerRequest(params, input);
req.setPath("/tag");
QueryResponse rsp = req.process(solrServer);
SolrDocumentList results= (SolrDocumentList) rsp.getResponse().get("response");
assertNotNull(rsp.getResponse().get("tags"));
assertNotNull(results.get(0));
}