use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.
the class BaseExpertFinderController method list.
@ApiOperation("Get expert list")
@RequestMapping(value = "/api/v1/user-management/users", method = GET)
public JsonResult<ExpertListSearchResultDTO> list(@ModelAttribute SearchExpertListDTO searchDTO) throws IOException, SolrServerException, NoSuchFieldException {
JsonResult result = new JsonResult<ExpertListSearchResultDTO>(NO_ERROR);
SolrQuery solrQuery = conversionService.convert(searchDTO, SolrQuery.class);
SearchResult searchResult = userService.search(solrQuery);
result.setResult(this.conversionService.convert(searchResult, ExpertListSearchResultDTO.class));
return result;
}
use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.
the class BaseDataSourceServiceImpl method search.
public SearchResult<DS> search(SolrQuery solrQuery) throws IOException, SolrServerException, NoSuchFieldException {
List<DS> dataSourceList;
QueryResponse solrResponse = solrSearch(solrQuery);
List<Long> docIdList = solrResponse.getResults().stream().map(solrDoc -> Long.parseLong(solrDoc.get(BaseSolrServiceImpl.ID).toString())).collect(Collectors.toList());
// We need to repeat sorting, because repository doesn't prevent order of passed ids
dataSourceList = dataSourceRepository.findByIdInAndDeletedIsNullAndPublishedTrue(docIdList);
dataSourceList.sort(Comparator.comparing(item -> docIdList.indexOf(item.getId())));
return new SearchResult<>(solrQuery, solrResponse, dataSourceList);
}
use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.
the class BaseUserServiceImpl method search.
public SearchResult<U> search(SolrQuery solrQuery) throws IOException, SolrServerException, NoSuchFieldException {
List<U> userList;
QueryResponse solrResponse = solrSearch(solrQuery);
List<Long> docIdList = solrResponse.getResults().stream().map(solrDoc -> Long.parseLong(solrDoc.get(BaseSolrServiceImpl.ID).toString())).collect(Collectors.toList());
userList = userRepository.findByIdIn(docIdList);
userList = userList.stream().sorted(Comparator.comparing(item -> docIdList.indexOf(item.getId()))).collect(Collectors.toList());
SearchResult<U> searchResult = new SearchResult<>(solrQuery, solrResponse, userList);
searchResult.setExcludedOptions(getExcludedOptions());
return searchResult;
}
use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.
the class BaseUserServiceImpl method getExcludedOptions.
private Map<String, List<String>> getExcludedOptions() throws IOException, SolrServerException, NoSuchFieldException {
SolrQuery solrQuery = conversionService.convert(new SearchExpertListDTO(true), SolrQuery.class);
QueryResponse solrResponse = solrSearch(solrQuery);
SearchResult<Long> searchResult = new SearchResult<>(solrQuery, solrResponse, Collections.<Long>emptyList());
return searchResult.excludedOptions();
}
use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.
the class BaseGlobalSearchServiceImpl method search.
@Override
public // TODO refactor, move out converting code
GlobalSearchResultDTO search(final Long userId, final SearchGlobalDTO searchDTO) throws SolrServerException, NoSuchFieldException, IOException {
searchDTO.setResultFields(ID, SYSTEM_ID, TITLE, TYPE, BREADCRUMBS);
final String[] collections = calculateCollections(searchDTO);
searchDTO.setCollections(collections);
final String tenantId = TenantContext.getCurrentTenant().toString();
final SolrQuery query = conversionService.convert(searchDTO, SolrQuery.class);
query.setQuery(buildSearchString(searchDTO.getQuery(), userId, tenantId));
setupHighlight(searchDTO.getQuery(), query);
final QueryResponse response = solrService.search(collections[0], query);
final SearchResult<SolrDocument> searchResult = new SearchResult<>(query, response, response.getResults());
return conversionService.convert(searchResult, GlobalSearchResultDTO.class);
}
Aggregations