本文整理了Java中org.apache.solr.client.solrj.request.QueryRequest.<init>
方法的一些代码示例,展示了QueryRequest.<init>
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryRequest.<init>
方法的具体详情如下:
包路径:org.apache.solr.client.solrj.request.QueryRequest
类名称:QueryRequest
方法名:<init>
暂无
代码示例来源:origin: apache/nifi
private String getFieldNameOfUniqueKey() {
final SolrQuery solrQuery = new SolrQuery();
try {
solrQuery.setRequestHandler("/schema/uniquekey");
final QueryRequest req = new QueryRequest(solrQuery);
if (isBasicAuthEnabled()) {
req.setBasicAuthCredentials(getUsername(), getPassword());
}
return(req.process(getSolrClient()).getResponse().get("uniqueKey").toString());
} catch (SolrServerException | IOException e) {
getLogger().error("Solr query to retrieve uniqueKey-field failed due to {}", new Object[]{solrQuery.toString(), e}, e);
throw new ProcessException(e);
}
}
代码示例来源:origin: apache/nifi
StopWatch timer = new StopWatch(true);
final QueryRequest req = new QueryRequest(solrQuery);
if (isBasicAuthEnabled()) {
req.setBasicAuthCredentials(getUsername(), getPassword());
代码示例来源:origin: apache/nifi
final QueryRequest req = new QueryRequest(solrQuery);
if (isBasicAuthEnabled()) {
req.setBasicAuthCredentials(getUsername(), getPassword());
代码示例来源:origin: apache/metron
public QueryRequest getListCollectionsRequest() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(SolrConstants.REQUEST_ACTION, CollectionParams.CollectionAction.LIST.name());
QueryRequest request = new QueryRequest(params);
request.setPath(SolrConstants.REQUEST_COLLECTIONS_PATH);
return request;
}
}
代码示例来源:origin: apache/metron
public QueryRequest getCreateCollectionsRequest(String name, int numShards, int replicationFactor) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(SolrConstants.REQUEST_ACTION, CollectionParams.CollectionAction.CREATE.name());
params.set(SolrConstants.REQUEST_NAME, name);
params.set(SolrConstants.REQUEST_NUM_SHARDS, numShards);
params.set(SolrConstants.REQUEST_REPLICATION_FACTOR, replicationFactor);
params.set(SolrConstants.REQUEST_COLLECTION_CONFIG_NAME, name);
QueryRequest request = new QueryRequest(params);
request.setPath(SolrConstants.REQUEST_COLLECTIONS_PATH);
return request;
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-solr
QueryResponse query(String collection, SolrParams solrParams)
throws IOException, SolrServerException {
QueryRequest query = new QueryRequest(solrParams);
return process(collection, query);
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-solrj
public QueryResponse query(SolrParams params) throws SolrServerException {
return new QueryRequest( params ).process( this );
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-solrj
public QueryResponse query(SolrParams params, METHOD method) throws SolrServerException {
return new QueryRequest( params, method ).process( this );
}
代码示例来源:origin: org.apache.solr/solr-solrj
/**
* Performs a query to the Solr server
*
* @param collection the Solr collection to query
* @param params an object holding all key/value parameters to send along the request
*
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
* from the server
*
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public QueryResponse query(String collection, SolrParams params) throws SolrServerException, IOException {
return new QueryRequest(params).process(this, collection);
}
代码示例来源:origin: com.hynnet/solr-solrj
/**
* Performs a query to the Solr server
*
* @param collection the Solr collection to query
* @param params an object holding all key/value parameters to send along the request
*
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
* from the server
*
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public QueryResponse query(String collection, SolrParams params) throws SolrServerException, IOException {
return new QueryRequest(params).process(this, collection);
}
代码示例来源:origin: org.apache.solr/solr-solrj
/**
* Performs a query to the Solr server
*
* @param collection the Solr collection to query
* @param params an object holding all key/value parameters to send along the request
* @param method specifies the HTTP method to use for the request, such as GET or POST
*
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
* from the server
*
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public QueryResponse query(String collection, SolrParams params, METHOD method) throws SolrServerException, IOException {
return new QueryRequest(params, method).process(this, collection);
}
代码示例来源:origin: com.hynnet/solr-solrj
/**
* Performs a query to the Solr server
*
* @param collection the Solr collection to query
* @param params an object holding all key/value parameters to send along the request
* @param method specifies the HTTP method to use for the request, such as GET or POST
*
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
* from the server
*
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public QueryResponse query(String collection, SolrParams params, METHOD method) throws SolrServerException, IOException {
return new QueryRequest(params, method).process(this, collection);
}
代码示例来源:origin: org.apache.solr/solr-solrj
private static Set<String> fetchLiveNodes(SolrClient client) throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", "CLUSTERSTATUS");
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
NamedList cluster = (SimpleOrderedMap) client.request(request).get("cluster");
Set<String> liveNodes = new HashSet((List<String>)(cluster.get("live_nodes")));
return liveNodes;
}
代码示例来源:origin: org.apache.solr/solr-solrj
public NamedList<Double> call() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
HttpSolrClient solrClient = cache.getHttpSolrClient(baseUrl);
params.add(DISTRIB, "false");
params.add("fq","{!significantTerms}");
for(String key : paramsMap.keySet()) {
params.add(key, paramsMap.get(key));
}
params.add("minDocFreq", Float.toString(minDocFreq));
params.add("maxDocFreq", Float.toString(maxDocFreq));
params.add("minTermLength", Integer.toString(minTermLength));
params.add("field", field);
params.add("numTerms", String.valueOf(numTerms*5));
QueryRequest request= new QueryRequest(params);
QueryResponse response = request.process(solrClient);
NamedList res = response.getResponse();
return res;
}
}
代码示例来源:origin: org.apache.solr/solr-solrj
public NamedList<Double> call() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
HttpSolrClient solrClient = cache.getHttpSolrClient(baseUrl);
params.add(DISTRIB, "false");
params.add("fq","{!igain}");
for(String key : paramsMap.keySet()) {
params.add(key, paramsMap.get(key));
}
params.add("outcome", outcome);
params.add("positiveLabel", Integer.toString(positiveLabel));
params.add("field", field);
params.add("numTerms", String.valueOf(numTerms));
QueryRequest request= new QueryRequest(params);
QueryResponse response = request.process(solrClient);
NamedList res = response.getResponse();
return res;
}
}
代码示例来源:origin: org.apache.solr/solr-solrj
public static JSONTupleStream create(SolrClient server, SolrParams requestParams) throws IOException, SolrServerException {
String p = requestParams.get("qt");
if(p != null) {
ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams;
modifiableSolrParams.remove("qt");
}
QueryRequest query = new QueryRequest( requestParams );
query.setPath(p);
query.setResponseParser(new InputStreamResponseParser("json"));
query.setMethod(SolrRequest.METHOD.POST);
NamedList<Object> genericResponse = server.request(query);
InputStream stream = (InputStream)genericResponse.get("stream");
InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
return new JSONTupleStream(reader);
}
代码示例来源:origin: com.hynnet/solr-solrj
public static JSONTupleStream create(SolrClient server, SolrParams requestParams) throws IOException, SolrServerException {
String p = requestParams.get("qt");
if(p != null) {
ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams;
modifiableSolrParams.remove("qt");
}
QueryRequest query = new QueryRequest( requestParams );
query.setPath(p);
query.setResponseParser(new InputStreamResponseParser("json"));
query.setMethod(SolrRequest.METHOD.POST);
NamedList<Object> genericResponse = server.request(query);
InputStream stream = (InputStream)genericResponse.get("stream");
InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
return new JSONTupleStream(reader);
}
代码示例来源:origin: com.sitewhere/sitewhere-solr
@Override
public JsonNode executeQueryWithRawResponse(String queryString) throws SiteWhereException {
try {
LOGGER.debug("About to execute Solr search with query string: " + queryString);
NoOpResponseParser rawJsonResponseParser = new NoOpResponseParser();
rawJsonResponseParser.setWriterType("json");
SolrQuery query = new SolrQuery();
query.add(createParamsFromQueryString(queryString));
QueryRequest request = new QueryRequest(query);
request.setResponseParser(rawJsonResponseParser);
NamedList<?> results = getSolr().getSolrClient().request(request);
return MAPPER.readTree((String) results.get("response"));
} catch (SolrServerException e) {
throw new SiteWhereException("Unable to execute query.", e);
} catch (IOException e) {
throw new SiteWhereException("Unable to execute query.", e);
}
}
代码示例来源:origin: org.apache.nifi/nifi-solr-processors
private String getFieldNameOfUniqueKey() {
final SolrQuery solrQuery = new SolrQuery();
try {
solrQuery.setRequestHandler("/schema/uniquekey");
final QueryRequest req = new QueryRequest(solrQuery);
if (isBasicAuthEnabled()) {
req.setBasicAuthCredentials(getUsername(), getPassword());
}
return(req.process(getSolrClient()).getResponse().get("uniqueKey").toString());
} catch (SolrServerException | IOException e) {
getLogger().error("Solr query to retrieve uniqueKey-field failed due to {}", new Object[]{solrQuery.toString(), e}, e);
throw new ProcessException(e);
}
}
代码示例来源:origin: sitewhere/sitewhere
@Override
public JsonNode executeQueryWithRawResponse(String queryString) throws SiteWhereException {
try {
getLogger().debug("About to execute Solr search with query string: " + queryString);
NoOpResponseParser rawJsonResponseParser = new NoOpResponseParser();
rawJsonResponseParser.setWriterType("json");
SolrQuery query = new SolrQuery();
query.add(createParamsFromQueryString(queryString));
QueryRequest request = new QueryRequest(query);
request.setResponseParser(rawJsonResponseParser);
NamedList<?> results = getSolrConnection().getSolrClient().request(request);
return MAPPER.readTree((String) results.get("response"));
} catch (SolrServerException e) {
throw new SiteWhereException("Unable to execute query.", e);
} catch (IOException e) {
throw new SiteWhereException("Unable to execute query.", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!