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 -
Method Summary
Modifier and TypeMethodDescriptionvoidOSGi callback to activate this component instance.addOrUpdateEvent(String id, Function<Optional<Event>, Optional<Event>> updateFunction, String orgId, org.opencastproject.security.api.User user) Adds or updates the event in the search index.addOrUpdateSeries(String id, Function<Optional<Series>, Optional<Series>> updateFunction, String orgId, org.opencastproject.security.api.User user) Adds or updates the series in the search index.addOrUpdateTheme(long id, Function<Optional<IndexTheme>, Optional<IndexTheme>> updateFunction, String orgId, org.opencastproject.security.api.User user) Adds or updates the theme in the search index.voidbulkEventUpdate(List<Event> eventList) Adds the recording events to the search index or updates it accordingly if it is there.voidbulkSeriesUpdate(List<Series> seriesList) Add or update a range of series in the search index.voidbulkThemeUpdate(List<IndexTheme> themeList) Adds or updates the themes in the search index.voidOSGi callback to deactivate this component.booleandeleteEvent(String eventId, String orgId) Delete event from index.booleandeleteSeries(String seriesId, String orgId) Delete series from index.booleandeleteTheme(String themeId, String orgId) Delete theme from index.org.opencastproject.elasticsearch.api.SearchResult<Event> getByQuery(EventSearchQuery query) org.opencastproject.elasticsearch.api.SearchResult<Series> getByQuery(SeriesSearchQuery query) org.opencastproject.elasticsearch.api.SearchResult<IndexTheme> getByQuery(ThemeSearchQuery query) String[]Loads the event from the search index if it exists.Loads the series from the search index if it exists.Loads the theme from the search index if it exists.voidOSGi callback for configuration changes.voidsetListProvidersService(org.opencastproject.list.api.ListProvidersService listProvidersService) voidunsetListProvidersService(org.opencastproject.list.api.ListProvidersService listProvidersService) Methods inherited from class org.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex
activate, bulkUpdate, clear, close, delete, executeQuery, getClient, getIndexName, getIndexVersion, getSearchRequest, getSubIndexIdentifier, getTermsForField, getTotalHits, init, update
-
Constructor Details
-
ElasticsearchIndex
public ElasticsearchIndex()
-
-
Method Details
-
setListProvidersService
public void setListProvidersService(org.opencastproject.list.api.ListProvidersService listProvidersService) -
unsetListProvidersService
public void unsetListProvidersService(org.opencastproject.list.api.ListProvidersService listProvidersService) -
activate
public void activate(org.osgi.framework.BundleContext bundleContext, Map<String, Object> properties) throws org.osgi.service.component.ComponentExceptionOSGi callback to activate this component instance.- Parameters:
bundleContext- The bundle contextproperties- The configuration- Throws:
org.osgi.service.component.ComponentException- If the search index cannot be initialized
-
deactivate
OSGi callback to deactivate this component.- Throws:
IOException- If closing the index fails
-
modified
OSGi callback for configuration changes.- Overrides:
modifiedin classorg.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex- Parameters:
properties- The configuration
-
getDocumentTypes
- Specified by:
getDocumentTypesin classorg.opencastproject.elasticsearch.impl.AbstractElasticsearchIndex- See Also:
-
getEvent
public Optional<Event> getEvent(String mediaPackageId, String 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 identifierorganization- The organizationuser- The user- Returns:
- the event (optional)
- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- If querying the search index failsIllegalStateException- If multiple events with the same identifier are found
-
getSeries
public Optional<Series> getSeries(String seriesId, String 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 identifierorganization- The organizationuser- The user- Returns:
- the series (optional)
- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- If querying the search index failsIllegalStateException- If multiple series with the same identifier are found
-
getTheme
public Optional<IndexTheme> getTheme(long themeId, String organization, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.SearchIndexException Loads the theme from the search index if it exists.- Parameters:
themeId- The theme identifierorganization- The organizationuser- The user- Returns:
- the theme wrapped in an optional
- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- If querying the search index failsIllegalStateException- If multiple themes with the same identifier are found
-
addOrUpdateEvent
public Optional<Event> addOrUpdateEvent(String id, Function<Optional<Event>, Optional<Event>> updateFunction, String orgId, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.SearchIndexExceptionAdds 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 updateupdateFunction- The function that does the actual updatingorgId- The organization the event belongs touser- The user- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- Thrown if unable to update the event.
-
bulkEventUpdate
public void bulkEventUpdate(List<Event> eventList) 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, String orgId, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.SearchIndexExceptionAdds 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 addupdateFunction- The function that does the actual updatingorgId- The organization the series belongs touser- 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
-
addOrUpdateTheme
public Optional<IndexTheme> addOrUpdateTheme(long id, Function<Optional<IndexTheme>, Optional<IndexTheme>> updateFunction, String orgId, org.opencastproject.security.api.User user) throws org.opencastproject.elasticsearch.api.SearchIndexExceptionAdds or updates the theme in the search index. Uses a locking mechanism to avoid issues like Lost Update.- Parameters:
id- The id of the theme to updateupdateFunction- The function that does the actual updatingorgId- The organization the theme belongs touser- The user- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- Thrown if unable to update the theme.
-
bulkThemeUpdate
public void bulkThemeUpdate(List<IndexTheme> themeList) throws org.opencastproject.elasticsearch.api.SearchIndexException Adds or updates the themes in the search index.- Parameters:
themeList- The themes to update- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- Thrown if unable to add or update the themes.
-
deleteEvent
public boolean deleteEvent(String eventId, String orgId) throws org.opencastproject.elasticsearch.api.SearchIndexException Delete event from index.- Parameters:
eventId- The event identifierorgId- 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, String orgId) throws org.opencastproject.elasticsearch.api.SearchIndexException Delete series from index.- Parameters:
seriesId- The series identifierorgId- 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
-
deleteTheme
public boolean deleteTheme(String themeId, String orgId) throws org.opencastproject.elasticsearch.api.SearchIndexException Delete theme from index.- Parameters:
themeId- The theme identifierorgId- 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:
SearchResultcollection ofEventfrom 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:
SearchResultcollection ofSeriesfrom a query.- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- Thrown if there is an error getting the results.
-
getByQuery
public org.opencastproject.elasticsearch.api.SearchResult<IndexTheme> getByQuery(ThemeSearchQuery query) throws org.opencastproject.elasticsearch.api.SearchIndexException - Parameters:
query- The query to use to retrieve the themes that match the query- Returns:
SearchResultcollection ofIndexThemefrom a query.- Throws:
org.opencastproject.elasticsearch.api.SearchIndexException- Thrown if there is an error getting the results.
-