Search in sources :

Example 1 with ThemeQueryBuilder

use of org.opencastproject.index.service.impl.index.theme.ThemeQueryBuilder in project opencast by opencast.

the class AbstractSearchIndex method getByQuery.

/**
 * @param query
 *          The query to use to retrieve the themes that match the query
 * @return {@link SearchResult} collection of {@link Theme} from a query.
 * @throws SearchIndexException
 *           Thrown if there is an error getting the results.
 */
public SearchResult<Theme> getByQuery(ThemeSearchQuery query) throws SearchIndexException {
    logger.debug("Searching index using theme query '{}'", query);
    // Create the request builder
    SearchRequestBuilder requestBuilder = getSearchRequestBuilder(query, new ThemeQueryBuilder(query));
    try {
        return executeQuery(query, requestBuilder, new Fn<SearchMetadataCollection, Theme>() {

            @Override
            public Theme apply(SearchMetadataCollection metadata) {
                try {
                    return ThemeIndexUtils.toTheme(metadata);
                } catch (IOException e) {
                    return chuck(e);
                }
            }
        });
    } catch (Throwable t) {
        throw new SearchIndexException("Error querying theme index", t);
    }
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) SearchMetadataCollection(org.opencastproject.matterhorn.search.impl.SearchMetadataCollection) SearchIndexException(org.opencastproject.matterhorn.search.SearchIndexException) ThemeQueryBuilder(org.opencastproject.index.service.impl.index.theme.ThemeQueryBuilder) Theme(org.opencastproject.index.service.impl.index.theme.Theme) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)1 Theme (org.opencastproject.index.service.impl.index.theme.Theme)1 ThemeQueryBuilder (org.opencastproject.index.service.impl.index.theme.ThemeQueryBuilder)1 SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)1 SearchMetadataCollection (org.opencastproject.matterhorn.search.impl.SearchMetadataCollection)1