use of org.jbei.ice.lib.dto.entry.EntryType in project ice by JBEI.
the class SearchResource method search.
/**
* Keyword search
*
* @param queryString keywords to search on
* @param searchWeb whether to perform a web of registry search or not
* @param offset result start
* @param limit result count upper limit
* @param sort result sort
* @param asc true if return results in ascending order, false otherwise
* @return wrapper around list of search results conforming to query params
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response search(@QueryParam("q") final String queryString, @DefaultValue("false") @QueryParam("webSearch") final boolean searchWeb, @DefaultValue("0") @QueryParam("offset") final int offset, @DefaultValue("15") @QueryParam("limit") final int limit, @DefaultValue("relevance") @QueryParam("sort") final String sort, @DefaultValue("false") @QueryParam("asc") final boolean asc) {
final String userId = getUserId();
if (StringUtils.isEmpty(userId) && !searchWeb) {
return super.respond(Response.Status.FORBIDDEN);
}
log(userId, "query \'" + queryString + '\'');
final SearchQuery query = new SearchQuery();
query.setQueryString(queryString);
final SearchQuery.Parameters parameters = query.getParameters();
parameters.setRetrieveCount(limit);
parameters.setStart(offset);
parameters.setSortAscending(asc);
parameters.setSortField(ColumnField.valueOf(sort.toUpperCase()));
final List<EntryType> types = Arrays.asList(EntryType.values());
query.setEntryTypes(types);
return super.respond(controller.runSearch(userId, query));
}
Aggregations