use of org.opennms.newts.api.search.query.QueryParser in project newts by OpenNMS.
the class SearchResource method search.
@GET
@Timed
public Collection<SearchResultDTO> search(@QueryParam("q") Optional<String> query, @QueryParam("context") Optional<String> contextId) {
checkArgument(query.isPresent(), "missing required query parameter (q=<argument>)");
QueryParser qp = new QueryParser();
Query parsedQuery;
try {
parsedQuery = qp.parse(query.get());
} catch (ParseException e) {
throw new WebApplicationException(e, Response.status(Status.BAD_REQUEST).entity("Invalid query " + query.get()).build());
}
Context context = contextId.isPresent() ? new Context(contextId.get()) : Context.DEFAULT_CONTEXT;
return Transform.searchResultDTOs(m_searcher.search(context, parsedQuery));
}
Aggregations