Java Code Examples for org.apache.solr.common.params.CursorMarkParams#CURSOR_MARK_START

The following examples show how to use org.apache.solr.common.params.CursorMarkParams#CURSOR_MARK_START . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DelegatingCursor.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected DelegatingCursor(SolrQuery query, String initalCursorMark) {

		this.referenceQuery = query;
		this.cursorMark = StringUtils.hasText(initalCursorMark) ? initalCursorMark : CursorMarkParams.CURSOR_MARK_START;
		this.state = State.REDAY;
		this.delegate = Collections.<T> emptyList().iterator();
	}
 
Example 2
Source File: SolrEntityProcessor.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * The following method changes the rowIterator mutable field. It requires
 * external synchronization. 
 */
protected void buildIterator() {
  if (rowIterator != null)  {
    SolrDocumentListIterator documentListIterator = (SolrDocumentListIterator) rowIterator;
    if (!documentListIterator.hasNext() && documentListIterator.hasMoreRows()) {
      nextPage();
    }
  } else {
    boolean cursor = Boolean.parseBoolean(context
        .getResolvedEntityAttribute(CursorMarkParams.CURSOR_MARK_PARAM));
    rowIterator = !cursor ? new SolrDocumentListIterator(new SolrDocumentList())
        : new SolrDocumentListCursor(new SolrDocumentList(), CursorMarkParams.CURSOR_MARK_START);
    nextPage();
  }
}
 
Example 3
Source File: DelegatingCursor.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected DelegatingCursor(SolrQuery query) {
	this(query, CursorMarkParams.CURSOR_MARK_START);
}
 
Example 4
Source File: SolrMetaAlertSearchDao.java    From metron with Apache License 2.0 4 votes vote down vote up
@Override
public SearchResponse getAllMetaAlertsForAlert(String guid) throws InvalidSearchException {
  if (guid == null || guid.trim().isEmpty()) {
    throw new InvalidSearchException("Guid cannot be empty");
  }

  // Searches for all alerts containing the meta alert guid in it's "metalerts" array
  // The query has to match the parentFilter to avoid errors.  Guid must also be explicitly
  // included.
  String activeClause =
      MetaAlertConstants.STATUS_FIELD + ":" + MetaAlertStatus.ACTIVE.getStatusString();
  String guidClause = Constants.GUID + ":" + guid;
  String fullClause = "{!parent which=" + activeClause + "}" + guidClause;
  String metaalertTypeClause = config.getSourceTypeField() + ":" + MetaAlertConstants.METAALERT_TYPE;
  SolrQuery solrQuery = new SolrQuery()
      .setQuery(fullClause)
      .setFields("*", "[child parentFilter=" + metaalertTypeClause + " limit=999]")
      .addSort(Constants.GUID,
          SolrQuery.ORDER.asc); // Just do basic sorting to track where we are

  // Use Solr's Cursors to handle the paging, rather than doing it manually.
  List<SearchResult> allResults = new ArrayList<>();
  try {
    String cursorMark = CursorMarkParams.CURSOR_MARK_START;
    boolean done = false;
    while (!done) {
      solrQuery.set(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark);
      QueryResponse rsp = solrClient.query(METAALERTS_COLLECTION, solrQuery);
      String nextCursorMark = rsp.getNextCursorMark();
      rsp.getResults().stream()
          .map(solrDocument -> SolrUtilities.getSearchResult(solrDocument, null,
                  solrSearchDao.getAccessConfig().getIndexSupplier()))
          .forEachOrdered(allResults::add);
      if (cursorMark.equals(nextCursorMark)) {
        done = true;
      }
      cursorMark = nextCursorMark;
    }
  } catch (IOException | SolrServerException e) {
    throw new InvalidSearchException("Unable to complete search", e);
  }

  SearchResponse searchResponse = new SearchResponse();
  searchResponse.setResults(allResults);
  searchResponse.setTotal(allResults.size());
  return searchResponse;
}