Search in sources :

Example 1 with EventQueryBuilder

use of org.opencastproject.index.service.impl.index.event.EventQueryBuilder in project opencast by opencast.

the class AbstractSearchIndex method getByQuery.

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

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

Aggregations

IOException (java.io.IOException)1 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)1 Event (org.opencastproject.index.service.impl.index.event.Event)1 EventQueryBuilder (org.opencastproject.index.service.impl.index.event.EventQueryBuilder)1 SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)1 SearchMetadataCollection (org.opencastproject.matterhorn.search.impl.SearchMetadataCollection)1