Class DiscoverResultIterator<T extends ReloadableEntity,PK extends Serializable>

java.lang.Object
org.dspace.discovery.DiscoverResultIterator<T,PK>
Type Parameters:
T - the type of the indexed object
PK - the type of the id of the indexed object
All Implemented Interfaces:
Iterator<T>
Direct Known Subclasses:
DiscoverResultItemIterator

public class DiscoverResultIterator<T extends ReloadableEntity,PK extends Serializable> extends Object implements Iterator<T>
Implementation of Iterator to iterate over the discover search result.
Author:
Luca Giamminonni (luca.giamminonni at 4science.it)
  • Constructor Details

    • DiscoverResultIterator

      public DiscoverResultIterator(Context context, DiscoverQuery discoverQuery)
      Constructor for global search without scope and unlimited results.
    • DiscoverResultIterator

      public DiscoverResultIterator(Context context, DiscoverQuery discoverQuery, boolean uncacheEntities)
      Constructor with optional uncacheEntities flag.
    • DiscoverResultIterator

      public DiscoverResultIterator(Context context, IndexableObject<?,?> scopeObject, DiscoverQuery discoverQuery)
      Constructor for scoped search without a limit on the number of results.
    • DiscoverResultIterator

      public DiscoverResultIterator(Context context, IndexableObject<?,?> scopeObject, DiscoverQuery discoverQuery, boolean uncacheEntities, int maxResults)
      Full constructor with all options.
  • Method Details

    • hasNext

      public boolean hasNext()
      Checks if there are more elements to iterate over. If the maximum number of results has been reached, it returns false. Otherwise, it checks the current slot iterator or fetches the next batch of results.
      Specified by:
      hasNext in interface Iterator<T extends ReloadableEntity>
      Returns:
      true if there are more elements, false otherwise
    • next

      public T next()
      Returns the next element in the iteration.
      Specified by:
      next in interface Iterator<T extends ReloadableEntity>
    • getTotalSearchResults

      public long getTotalSearchResults()
      Returns the total number of search results.

      This method calculates the total number of search results based on the current search query. If the slot iterator has not been initialized, it updates the iterator.

      Returns:
      the total number of search results as a long
    • getNextIndexableObject

      protected IndexableObject getNextIndexableObject()
      Retrieves the next indexable object. Throws NoSuchElementException if there are no more elements.