Class ElasticsearchIndex

java.lang.Object
org.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex
org.opencastproject.elasticsearch.index.ElasticsearchIndex
All Implemented Interfaces:
SearchIndex

public class ElasticsearchIndex extends AbstractElasticsearchIndex
An index implementation based on ElasticSearch that serves the Admin UI API and the External API with data aggregated from multiple services.
  • Constructor Details

    • ElasticsearchIndex

      public ElasticsearchIndex()
  • Method Details

    • setListProvidersService

      public void setListProvidersService(ListProvidersService listProvidersService)
    • unsetListProvidersService

      public void unsetListProvidersService(ListProvidersService listProvidersService)
    • activate

      public void activate(org.osgi.framework.BundleContext bundleContext, Map<String,Object> properties) throws org.osgi.service.component.ComponentException
      OSGi callback to activate this component instance.
      Parameters:
      bundleContext - The bundle context
      properties - The configuration
      Throws:
      org.osgi.service.component.ComponentException - If the search index cannot be initialized
    • deactivate

      public void deactivate() throws IOException
      OSGi callback to deactivate this component.
      Throws:
      IOException - If closing the index fails
    • modified

      public void modified(Map<String,Object> properties)
      OSGi callback for configuration changes.
      Overrides:
      modified in class AbstractElasticsearchIndex
      Parameters:
      properties - The configuration
    • getDocumentTypes

      public String[] getDocumentTypes()
      Description copied from class: AbstractElasticsearchIndex
      Returns an array of document types for the index. For every one of these, the corresponding document type definition will be loaded.
      Specified by:
      getDocumentTypes in class AbstractElasticsearchIndex
      Returns:
      the document types
      See Also:
    • getEvent

      public Optional<Event> getEvent(String mediaPackageId, String organization, User user) throws SearchIndexException
      Loads the event from the search index if it exists.
      Parameters:
      mediaPackageId - The media package identifier
      organization - The organization
      user - The user
      Returns:
      the event (optional)
      Throws:
      SearchIndexException - If querying the search index fails
      IllegalStateException - If multiple events with the same identifier are found
    • getSeries

      public Optional<Series> getSeries(String seriesId, String organization, User user) throws SearchIndexException
      Loads the series from the search index if it exists.
      Parameters:
      seriesId - The series identifier
      organization - The organization
      user - The user
      Returns:
      the series (optional)
      Throws:
      SearchIndexException - If querying the search index fails
      IllegalStateException - If multiple series with the same identifier are found
    • addOrUpdateEvent

      public Optional<Event> addOrUpdateEvent(String id, Function<Optional<Event>,Optional<Event>> updateFunction, String orgId, User user) throws SearchIndexException
      Adds or updates the event in the search index. Uses a locking mechanism to avoid issues like Lost Update.
      Parameters:
      id - The id of the event to update
      updateFunction - The function that does the actual updating
      orgId - The organization the event belongs to
      user - The user
      Throws:
      SearchIndexException - Thrown if unable to update the event.
    • bulkEventUpdate

      public void bulkEventUpdate(List<Event> eventList) throws SearchIndexException
      Adds the recording events to the search index or updates it accordingly if it is there.
      Parameters:
      eventList - The events to update
      Throws:
      SearchIndexException - If the events cannot be added or updated
    • addOrUpdateSeries

      public Optional<Series> addOrUpdateSeries(String id, Function<Optional<Series>,Optional<Series>> updateFunction, String orgId, User user) throws SearchIndexException
      Adds or updates the series in the search index. Uses a locking mechanism to avoid issues like Lost Update.
      Parameters:
      id - The id of the series to add
      updateFunction - The function that does the actual updating
      orgId - The organization the series belongs to
      user - The user
      Throws:
      SearchIndexException - Thrown if unable to add or update the series.
    • bulkSeriesUpdate

      public void bulkSeriesUpdate(List<Series> seriesList) throws SearchIndexException
      Add or update a range of series in the search index.
      Parameters:
      seriesList - The series to update
      Throws:
      SearchIndexException - If the series cannot be added or updated
    • deleteEvent

      public boolean deleteEvent(String eventId, String orgId) throws SearchIndexException
      Delete event from index.
      Parameters:
      eventId - The event identifier
      orgId - The organization id
      Returns:
      true if it was deleted, false if it couldn't be found
      Throws:
      SearchIndexException - If there was an error during deletion
    • deleteSeries

      public boolean deleteSeries(String seriesId, String orgId) throws SearchIndexException
      Delete series from index.
      Parameters:
      seriesId - The series identifier
      orgId - The organization id
      Returns:
      true if it was deleted, false if it couldn't be found
      Throws:
      SearchIndexException - If there was an error during deletion
    • getByQuery

      public SearchResult<Event> getByQuery(EventSearchQuery query) throws SearchIndexException
      Parameters:
      query - The query to use to retrieve the events that match the query
      Returns:
      SearchResult collection of Event from a query.
      Throws:
      SearchIndexException - Thrown if there is an error getting the results.
    • getByQuery

      public SearchResult<Series> getByQuery(SeriesSearchQuery query) throws SearchIndexException
      Parameters:
      query - The query to use to retrieve the series that match the query
      Returns:
      SearchResult collection of Series from a query.
      Throws:
      SearchIndexException - Thrown if there is an error getting the results.