List of usage examples for org.apache.solr.client.solrj SolrQuery getRequestHandler
public String getRequestHandler()
From source file:com.nridge.ds.solr.SolrDS.java
License:Open Source License
/** * Returns a <i>Document</i> representation of all documents * fetched from the underlying content source (using a wildcard * criteria)./* w ww . java 2 s . com*/ * <p> * <b>Note:</b> Depending on the size of the content source * behind this data source, this method could consume large * amounts of heap memory. Therefore, it should only be * used when the number of column and rows is known to be * small in size. * </p> * * @return Document hierarchy representing all documents in * the content source. * * @throws com.nridge.core.base.ds.DSException Data source related exception. */ @Override public Document fetch() throws DSException { Document solrDocument; Logger appLogger = mAppMgr.getLogger(this, "fetch"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); initialize(); DSCriteria dsCriteria = new DSCriteria("Solr Query"); dsCriteria.add(Solr.FIELD_QUERY_NAME, Field.Operator.EQUAL, Solr.QUERY_ALL_DOCUMENTS); SolrQuery solrQuery = mSolrQueryBuilder.create(dsCriteria); solrQuery.setStart(Solr.QUERY_OFFSET_DEFAULT); solrQuery.setRows(Solr.QUERY_PAGESIZE_DEFAULT); appLogger.debug(String.format("%s: %s %s", dsCriteria.getName(), mSolrIdentity, solrQuery.toString())); SolrResponseBuilder solrResponseBuilder = createResponseBuilder(); QueryResponse queryResponse = queryExecute(solrQuery); solrDocument = solrResponseBuilder.extract(queryResponse); DataBag headerBag = Solr.getHeader(solrDocument); if (headerBag != null) headerBag.setValueByName("collection_name", getCollectionName()); String requestHandler = solrQuery.getRequestHandler(); solrResponseBuilder.updateHeader(mBaseSolrURL, solrQuery.getQuery(), requestHandler, solrQuery.getStart(), solrQuery.getRows()); appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return solrDocument; }
From source file:com.nridge.ds.solr.SolrDS.java
License:Open Source License
/** * Returns a <i>Document</i> representation of the documents * that match the <i>DSCriteria</i> specified in the parameter. * <p>//from ww w . j a v a 2 s.com * <b>Note:</b> Depending on the size of the content source * behind this data source and the criteria specified, this * method could consume large amounts of heap memory. * Therefore, the developer is encouraged to use the alternative * method for fetch where an offset and limit parameter can be * specified. * </p> * * @param aDSCriteria Data source criteria. * * @return Document hierarchy representing all documents that * match the criteria in the content source. * * @throws com.nridge.core.base.ds.DSException Data source related exception. * * @see <a href="http://lucene.apache.org/solr/guide/7_6/common-query-parameters.html">Solr Common Query Parametersr</a> * @see <a href="https://lucene.apache.org/solr/guide/7_6/the-standard-query-parser.html">Solr Standard Query Parserr</a> */ @Override public Document fetch(DSCriteria aDSCriteria) throws DSException { Document solrDocument; Logger appLogger = mAppMgr.getLogger(this, "fetch"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); initialize(); SolrQuery solrQuery = mSolrQueryBuilder.create(aDSCriteria); appLogger.debug(String.format("%s: %s %s", aDSCriteria.getName(), mSolrIdentity, solrQuery.toString())); SolrResponseBuilder solrResponseBuilder = createResponseBuilder(); QueryResponse queryResponse = queryExecute(solrQuery); solrDocument = solrResponseBuilder.extract(queryResponse); DataBag headerBag = Solr.getHeader(solrDocument); if (headerBag != null) headerBag.setValueByName("collection_name", getCollectionName()); String requestHandler = solrQuery.getRequestHandler(); Integer startPosition = solrQuery.getStart(); if (startPosition == null) startPosition = Solr.QUERY_OFFSET_DEFAULT; Integer totalRows = solrQuery.getRows(); if (totalRows == null) totalRows = Solr.QUERY_PAGESIZE_DEFAULT; solrResponseBuilder.updateHeader(mBaseSolrURL, solrQuery.getQuery(), requestHandler, startPosition, totalRows); if (Solr.isCriteriaParentChild(aDSCriteria)) { SolrParentChild solrParentChild = new SolrParentChild(mAppMgr, this); solrParentChild.expand(solrDocument, aDSCriteria); } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return solrDocument; }
From source file:com.nridge.ds.solr.SolrDS.java
License:Open Source License
/** * Returns a <i>Document</i> representation of the documents * that match the <i>DSCriteria</i> specified in the parameter. * In addition, this method offers a paging mechanism where the * starting offset and a fetch limit can be applied to each * content fetch query./* w ww .j av a 2 s . com*/ * * @param aDSCriteria Data source criteria. * @param anOffset Starting offset into the matching content rows. * @param aLimit Limit on the total number of rows to extract from * the content source during this fetch operation. * * @return Document hierarchy representing all documents that * match the criteria in the content source. (based on the offset * and limit values). * * @throws com.nridge.core.base.ds.DSException Data source related exception. * * @see <a href="http://lucene.apache.org/solr/guide/7_6/common-query-parameters.html">Solr Common Query Parametersr</a> * @see <a href="https://lucene.apache.org/solr/guide/7_6/the-standard-query-parser.html">Solr Standard Query Parserr</a> */ @Override public Document fetch(DSCriteria aDSCriteria, int anOffset, int aLimit) throws DSException { Document solrDocument; Logger appLogger = mAppMgr.getLogger(this, "fetch"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); initialize(); SolrQuery solrQuery = mSolrQueryBuilder.create(aDSCriteria); solrQuery.setStart(anOffset); solrQuery.setRows(aLimit); appLogger.debug(String.format("%s: %s %s", aDSCriteria.getName(), mSolrIdentity, solrQuery.toString())); SolrResponseBuilder solrResponseBuilder = createResponseBuilder(); QueryResponse queryResponse = queryExecute(solrQuery); solrDocument = solrResponseBuilder.extract(queryResponse, anOffset, aLimit); DataBag headerBag = Solr.getHeader(solrDocument); if (headerBag != null) headerBag.setValueByName("collection_name", getCollectionName()); String requestHandler = solrQuery.getRequestHandler(); solrResponseBuilder.updateHeader(mBaseSolrURL, solrQuery.getQuery(), requestHandler, anOffset, aLimit); if (Solr.isCriteriaParentChild(aDSCriteria)) { SolrParentChild solrParentChild = new SolrParentChild(mAppMgr, this); solrParentChild.expand(solrDocument, aDSCriteria); } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return solrDocument; }
From source file:uk.co.flax.biosolr.ontology.search.solr.SolrSearchEngine.java
License:Apache License
protected String getQueryUrl(SolrQuery query, String baseUrl) { StringBuilder queryUrl = new StringBuilder(baseUrl); if (StringUtils.isBlank(query.getRequestHandler())) { queryUrl.append("/select"); } else {//from w w w .ja v a 2 s.c o m queryUrl.append(query.getRequestHandler()); } queryUrl.append(ClientUtils.toQueryString(query, false)); return queryUrl.toString(); }