本文整理匯總了Java中org.apache.solr.client.solrj.SolrQuery.getRows方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrQuery.getRows方法的具體用法?Java SolrQuery.getRows怎麽用?Java SolrQuery.getRows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.getRows方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: search
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
public final Page<T> search(SolrQuery solrQuery, String fetch) throws SolrServerException, IOException {
QueryResponse queryResponse;
try {
queryResponse = solrClient.query(solrQuery);
} catch (IOException e) {
logger.error("Error querying solr server: ", e);
throw new SolrServerException(e);
}
List<T> results = new ArrayList<T>();
for(SolrDocument solrDocument : queryResponse.getResults()) {
T object = loadObjectForDocument(solrDocument);
enableProfilePostQuery(object, fetch);
results.add(object);
}
Integer pageSize = solrQuery.getRows();
Integer pageNumber = solrQuery.getStart() / pageSize ;
Page<T> page = new DefaultPageImpl<T>(results, pageNumber, pageSize);
return page;
}
示例2: searchForDocuments
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public Page<SolrDocument> searchForDocuments(SolrQuery solrQuery) throws SolrServerException, IOException {
QueryResponse queryResponse = solrClient.query(solrQuery);
Integer pageSize = solrQuery.getRows();
Integer pageNumber = solrQuery.getStart() / pageSize ;
Page<SolrDocument> page = new DefaultPageImpl<SolrDocument>(queryResponse.getResults(), pageNumber, pageSize);
return page;
}
示例3: addQueryOption
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public void addQueryOption(String key, String value, SolrQuery query) {
Integer currentRows = query.getRows();
Integer pageSize = Integer.valueOf(value);
query.setRows(pageSize);
if(query.getStart() != null && currentRows != null){
Integer page = query.getStart() / query.getRows();
query.setStart(page * pageSize);
}
}
示例4: addQueryOption
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public void addQueryOption(String key, String value, SolrQuery query) {
int rows = query.getRows() == null ? 24 : query.getRows();
int start = Integer.valueOf(value) * rows;
query.setStart(start);
}
示例5: getRecordReader
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public RecordReader<IntWritable, LWDocumentWritable> getRecordReader(
InputSplit split, JobConf job, Reporter reporter) throws IOException {
LWInputSplit lwSplit = (LWInputSplit) split;
SolrClient solr;
String collection = job.get(SOLR_COLLECTION);
String query = job.get(SOLR_QUERY, "*:*");
if (lwSplit.isZk) {
SolrSecurity.setSecurityConfig(job);
if (lwSplit.isShard) {
solr = new HttpSolrClient.Builder()
.withBaseSolrUrl(lwSplit.getConnectionUri())
.build();
} else {
// somehow the list of shard is unavailable
solr = new CloudSolrClient.Builder()
.withZkHost(lwSplit.getConnectionUri())
.build();
((CloudSolrClient) solr).setDefaultCollection(collection);
}
} else {
String connectionUri = lwSplit.getConnectionUri();
int queueSize = job.getInt("solr.client.queue.size", 100);
int threadCount = job.getInt("solr.client.threads", 1);
if (!connectionUri.endsWith("/")) {
connectionUri += "/";
}
connectionUri += collection;
solr = new ConcurrentUpdateSolrClient.Builder(connectionUri)
.withQueueSize(queueSize)
.withThreadCount(threadCount)
.build();
}
SolrQuery solrQuery = new SolrQuery(query);
solrQuery.set("distrib", false);
solrQuery.set("collection", collection);
if (solrQuery.getRows() == null) {
solrQuery.setRows(DEFAULT_PAGE_SIZE); // default page size
}
solrQuery.setSort(SolrQuery.SortClause.asc("id"));
return new LWRecordReader(solr, solrQuery, "*");
}