當前位置: 首頁>>代碼示例>>Java>>正文


Java SolrQuery.getRows方法代碼示例

本文整理匯總了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;
}
 
開發者ID:RBGKew,項目名稱:powop,代碼行數:23,代碼來源:SearchableDaoImpl.java

示例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;
}
 
開發者ID:RBGKew,項目名稱:powop,代碼行數:10,代碼來源:SearchableDaoImpl.java

示例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);
	}
}
 
開發者ID:RBGKew,項目名稱:powop,代碼行數:11,代碼來源:PageSizeQuery.java

示例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);
}
 
開發者ID:RBGKew,項目名稱:powop,代碼行數:8,代碼來源:PageNumberQuery.java

示例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, "*");
}
 
開發者ID:lucidworks,項目名稱:solr-hadoop-common,代碼行數:49,代碼來源:LWMapRedInputFormat.java


注:本文中的org.apache.solr.client.solrj.SolrQuery.getRows方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。