Search in sources :

Example 1 with SearchMetadata

use of org.opencastproject.matterhorn.search.SearchMetadata in project opencast by opencast.

the class AbstractSearchIndex method addOrUpdate.

/**
 * Add or update a series in the search index.
 *
 * @param series
 * @throws SearchIndexException
 */
public void addOrUpdate(Series series) throws SearchIndexException {
    logger.debug("Adding resource {} to search index", series);
    // if (!preparedIndices.contains(resource.getURI().getSite().getIdentifier())) {
    // try {
    // createIndex(resource.getURI().getSite());
    // } catch (IOException e) {
    // throw new SearchIndexException(e);
    // }
    // }
    // Add the resource to the index
    SearchMetadataCollection inputDocument = SeriesIndexUtils.toSearchMetadata(series);
    List<SearchMetadata<?>> resourceMetadata = inputDocument.getMetadata();
    ElasticsearchDocument doc = new ElasticsearchDocument(inputDocument.getIdentifier(), inputDocument.getDocumentType(), resourceMetadata);
    try {
        update(doc);
    } catch (Throwable t) {
        throw new SearchIndexException("Cannot write resource " + series + " to index", t);
    }
}
Also used : SearchMetadataCollection(org.opencastproject.matterhorn.search.impl.SearchMetadataCollection) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) SearchMetadata(org.opencastproject.matterhorn.search.SearchMetadata) ElasticsearchDocument(org.opencastproject.matterhorn.search.impl.ElasticsearchDocument)

Example 2 with SearchMetadata

use of org.opencastproject.matterhorn.search.SearchMetadata in project opencast by opencast.

the class AbstractSearchIndex method addOrUpdate.

/**
 * Adds or updates the theme in the search index.
 *
 * @param theme
 *          The theme to add
 * @throws SearchIndexException
 *           Thrown if unable to add or update the theme.
 */
public void addOrUpdate(Theme theme) throws SearchIndexException {
    logger.debug("Adding resource {} to search index", theme);
    // if (!preparedIndices.contains(resource.getURI().getSite().getIdentifier())) {
    // try {
    // createIndex(resource.getURI().getSite());
    // } catch (IOException e) {
    // throw new SearchIndexException(e);
    // }
    // }
    // Add the resource to the index
    SearchMetadataCollection inputDocument = ThemeIndexUtils.toSearchMetadata(theme);
    List<SearchMetadata<?>> resourceMetadata = inputDocument.getMetadata();
    ElasticsearchDocument doc = new ElasticsearchDocument(inputDocument.getIdentifier(), inputDocument.getDocumentType(), resourceMetadata);
    try {
        update(doc);
    } catch (Throwable t) {
        throw new SearchIndexException("Cannot write resource " + theme + " to index", t);
    }
}
Also used : SearchMetadataCollection(org.opencastproject.matterhorn.search.impl.SearchMetadataCollection) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) SearchMetadata(org.opencastproject.matterhorn.search.SearchMetadata) ElasticsearchDocument(org.opencastproject.matterhorn.search.impl.ElasticsearchDocument)

Example 3 with SearchMetadata

use of org.opencastproject.matterhorn.search.SearchMetadata in project opencast by opencast.

the class AbstractSearchIndex method addOrUpdate.

/**
 * Adds the recording event to the search index or updates it accordingly if it is there.
 *
 * @param event
 *          the recording event
 * @throws SearchIndexException
 *           if the event cannot be added or updated
 */
public void addOrUpdate(Event event) throws SearchIndexException {
    logger.debug("Adding resource {} to search index", event);
    // if (!preparedIndices.contains(resource.getURI().getSite().getIdentifier())) {
    // try {
    // createIndex(resource.getURI().getSite());
    // } catch (IOException e) {
    // throw new SearchIndexException(e);
    // }
    // }
    // Add the resource to the index
    SearchMetadataCollection inputDocument = EventIndexUtils.toSearchMetadata(event);
    List<SearchMetadata<?>> resourceMetadata = inputDocument.getMetadata();
    ElasticsearchDocument doc = new ElasticsearchDocument(inputDocument.getIdentifier(), inputDocument.getDocumentType(), resourceMetadata);
    try {
        update(doc);
    } catch (Throwable t) {
        throw new SearchIndexException("Cannot write resource " + event + " to index", t);
    }
}
Also used : SearchMetadataCollection(org.opencastproject.matterhorn.search.impl.SearchMetadataCollection) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) SearchMetadata(org.opencastproject.matterhorn.search.SearchMetadata) ElasticsearchDocument(org.opencastproject.matterhorn.search.impl.ElasticsearchDocument)

Example 4 with SearchMetadata

use of org.opencastproject.matterhorn.search.SearchMetadata in project opencast by opencast.

the class AbstractSearchIndex method addOrUpdate.

/**
 * Adds or updates the group in the search index.
 *
 * @param group
 *          The group to add
 * @throws SearchIndexException
 *           Thrown if unable to add or update the group.
 */
public void addOrUpdate(Group group) throws SearchIndexException {
    logger.debug("Adding resource {} to search index", group);
    // if (!preparedIndices.contains(resource.getURI().getSite().getIdentifier())) {
    // try {
    // createIndex(resource.getURI().getSite());
    // } catch (IOException e) {
    // throw new SearchIndexException(e);
    // }
    // }
    // Add the resource to the index
    SearchMetadataCollection inputDocument = GroupIndexUtils.toSearchMetadata(group);
    List<SearchMetadata<?>> resourceMetadata = inputDocument.getMetadata();
    ElasticsearchDocument doc = new ElasticsearchDocument(inputDocument.getIdentifier(), inputDocument.getDocumentType(), resourceMetadata);
    try {
        update(doc);
    } catch (Throwable t) {
        throw new SearchIndexException("Cannot write resource " + group + " to index", t);
    }
}
Also used : SearchMetadataCollection(org.opencastproject.matterhorn.search.impl.SearchMetadataCollection) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) SearchMetadata(org.opencastproject.matterhorn.search.SearchMetadata) ElasticsearchDocument(org.opencastproject.matterhorn.search.impl.ElasticsearchDocument)

Aggregations

SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)4 SearchMetadata (org.opencastproject.matterhorn.search.SearchMetadata)4 ElasticsearchDocument (org.opencastproject.matterhorn.search.impl.ElasticsearchDocument)4 SearchMetadataCollection (org.opencastproject.matterhorn.search.impl.SearchMetadataCollection)4