Class ElasticsearchIndex

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

public class ElasticsearchIndex extends org.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex
An index implementation based on ElasticSearch that serves the Admin UI API and the External API with data aggregated from multiple services.
  • Field Summary

    Fields inherited from class org.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex

    ELASTICSEARCH_PASSWORD_KEY, ELASTICSEARCH_SERVER_HOSTNAME_KEY, ELASTICSEARCH_SERVER_PORT_KEY, ELASTICSEARCH_SERVER_SCHEME_KEY, ELASTICSEARCH_USERNAME_KEY, indexSettingsPath
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    activate(org.osgi.framework.BundleContext bundleContext, Map<String,Object> properties)
    OSGi callback to activate this component instance.
    addOrUpdateEvent(String id, Function<Optional<Event>,Optional<Event>> updateFunction, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user)
    Adds or updates the event in the search index.
    addOrUpdateSeries(String id, Function<Optional<Series>,Optional<Series>> updateFunction, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user)
    Adds or updates the series in the search index.
    void
    bulkEventUpdate(List<Event> eventList, org.opencastproject.security.api.Organization organization)
    Adds the recording events to the search index or updates it accordingly if it is there.
    void
    Add or update a range of series in the search index.
    void
    OSGi callback to deactivate this component.
    boolean
    deleteEvent(String eventId, org.opencastproject.security.api.Organization organization)
    Delete event from index.
    boolean
    deleteSeries(String seriesId, org.opencastproject.security.api.Organization organization)
    Delete series from index.
    org.opencastproject.elasticsearch.api.SearchResult<Event>
     
    org.opencastproject.elasticsearch.api.SearchResult<Series>
     
     
    getEvent(String mediaPackageId, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user)
    Loads the event from the search index if it exists.
    getSeries(String seriesId, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user)
    Loads the series from the search index if it exists.
    void
    modified(Map<String,Object> properties)
    OSGi callback for configuration changes.

    Methods inherited from class org.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex

    activate, bulkUpdate, clear, close, delete, executeQuery, getClient, getIndexName, getIndexVersion, getSearchRequest, getSubIndexIdentifier, getTermsForField, getTotalHits, init, update

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ElasticsearchIndex

      public ElasticsearchIndex()
  • Method Details

    • 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 org.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex
      Parameters:
      properties - The configuration
    • getDocumentTypes

      public String[] getDocumentTypes()
      Specified by:
      getDocumentTypes in class org.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex
      See Also:
      • AbstractElasticsearchIndex.getDocumentTypes()
    • getEvent

      public Optional<Event> getEvent(String mediaPackageId, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.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:
      org.opencastproject.elasticsearch.api.SearchIndexException - If querying the search index fails
      IllegalStateException - If multiple events with the same identifier are found
    • getSeries

      public Optional<Series> getSeries(String seriesId, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.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:
      org.opencastproject.elasticsearch.api.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, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.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
      organization - The organization the event belongs to
      user - The user
      Throws:
      org.opencastproject.elasticsearch.api.SearchIndexException - Thrown if unable to update the event.
    • bulkEventUpdate

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

      public Optional<Series> addOrUpdateSeries(String id, Function<Optional<Series>,Optional<Series>> updateFunction, org.opencastproject.security.api.Organization organization, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.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
      organization - The organization the series belongs to
      user - The user
      Throws:
      org.opencastproject.elasticsearch.api.SearchIndexException - Thrown if unable to add or update the series.
    • bulkSeriesUpdate

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

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

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

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

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