Search in sources :

Example 1 with SolrException

use of com.odysseusinc.arachne.portal.model.solr.SolrException in project ArachneCentralAPI by OHDSI.

the class BaseSolrServiceImpl method indexBySolr.

@Override
public void indexBySolr(final List<? extends SolrEntity> entities) {
    try {
        final Map<SolrCollection, List<SolrEntity>> entitiesGroupByCollection = entities.stream().collect(Collectors.groupingBy(SolrEntity::getCollection));
        entitiesGroupByCollection.forEach((key, value) -> putDocuments(key.getName(), value.stream().map(this::getValuesByEntity).collect(Collectors.toList())));
    } catch (final Exception e) {
        throw new SolrException(e);
    }
}
Also used : SolrCollection(com.odysseusinc.arachne.portal.model.solr.SolrCollection) FieldList(com.odysseusinc.arachne.portal.service.impl.solr.FieldList) LinkedList(java.util.LinkedList) List(java.util.List) SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException)

Example 2 with SolrException

use of com.odysseusinc.arachne.portal.model.solr.SolrException in project ArachneCentralAPI by OHDSI.

the class BaseSolrServiceImpl method putDocuments.

@Override
public void putDocuments(final String collection, final List<Map<T, Object>> valuesList) {
    try {
        final List<SolrInputDocument> documents = valuesList.stream().map(v -> createSolrDocument(collection, v)).collect(Collectors.toList());
        final UpdateResponse updateResponse = solrClient.add(collection, documents);
        final UpdateResponse commitResponse = solrClient.commit(collection);
        if (commitResponse.getStatus() != 0 || updateResponse.getStatus() != 0) {
            throw new SolrServerException("Cannot index by Solr");
        }
    } catch (IOException | SolrServerException e) {
        throw new SolrException(e);
    }
}
Also used : Arrays(java.util.Arrays) BreadcrumbDTO(com.odysseusinc.arachne.portal.api.v1.dto.BreadcrumbDTO) FieldList(com.odysseusinc.arachne.portal.service.impl.solr.FieldList) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) SolrFieldExtractor(com.odysseusinc.arachne.portal.api.v1.dto.converters.SolrFieldExtractor) StringUtils(org.apache.commons.lang3.StringUtils) TenantContext(com.odysseusinc.arachne.portal.config.tenancy.TenantContext) BreadcrumbService(com.odysseusinc.arachne.portal.service.BreadcrumbService) SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SolrField(com.odysseusinc.arachne.portal.service.impl.solr.SolrField) Map(java.util.Map) Breadcrumb(com.odysseusinc.arachne.portal.service.impl.breadcrumb.Breadcrumb) LinkedList(java.util.LinkedList) ConversionService(org.springframework.core.convert.ConversionService) BaseSolrService(com.odysseusinc.arachne.portal.service.BaseSolrService) SolrValue(com.odysseusinc.arachne.portal.model.solr.SolrValue) Collection(java.util.Collection) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) AnnotationUtils(org.springframework.core.annotation.AnnotationUtils) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SolrFieldAnno(com.odysseusinc.arachne.portal.model.solr.SolrFieldAnno) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) SolrClient(org.apache.solr.client.solrj.SolrClient) SolrCollection(com.odysseusinc.arachne.portal.model.solr.SolrCollection) SolrEntity(com.odysseusinc.arachne.portal.model.solr.SolrEntity) List(java.util.List) SolrQuery(org.apache.solr.client.solrj.SolrQuery) Optional(java.util.Optional) Collections(java.util.Collections) UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse) SolrInputDocument(org.apache.solr.common.SolrInputDocument) BeanUtils(org.springframework.beans.BeanUtils) UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse) SolrInputDocument(org.apache.solr.common.SolrInputDocument) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException)

Example 3 with SolrException

use of com.odysseusinc.arachne.portal.model.solr.SolrException in project ArachneCentralAPI by OHDSI.

the class BaseSolrServiceImpl method putDocument.

@Override
public void putDocument(final String collection, final Long id, final Map<T, Object> values) {
    try {
        final SolrInputDocument document = createSolrDocument(collection, id, values);
        final UpdateResponse updateResponse = solrClient.add(collection, document);
        final UpdateResponse commitResponse = solrClient.commit(collection);
        if (commitResponse.getStatus() != 0 || updateResponse.getStatus() != 0) {
            throw new SolrServerException("Cannot index by Solr");
        }
    } catch (IOException | SolrServerException e) {
        throw new SolrException(e);
    }
}
Also used : UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse) SolrInputDocument(org.apache.solr.common.SolrInputDocument) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException)

Example 4 with SolrException

use of com.odysseusinc.arachne.portal.model.solr.SolrException in project ArachneCentralAPI by OHDSI.

the class BaseSolrServiceImpl method deleteByQuery.

@Override
public void deleteByQuery(final String collection, final String query) {
    try {
        solrClient.deleteByQuery(collection, query);
        solrClient.commit(collection);
    } catch (IOException | SolrServerException e) {
        throw new SolrException(e);
    }
}
Also used : SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException)

Example 5 with SolrException

use of com.odysseusinc.arachne.portal.model.solr.SolrException in project ArachneCentralAPI by OHDSI.

the class BaseSolrServiceImpl method indexBySolr.

@Override
public void indexBySolr(final SolrEntity entity) {
    try {
        final Map<T, Object> values = getValuesByEntity(entity);
        putDocument(entity.getCollection().getName(), entity.getId(), values);
    } catch (final Exception e) {
        throw new SolrException(e);
    }
}
Also used : SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) SolrException(com.odysseusinc.arachne.portal.model.solr.SolrException)

Aggregations

SolrException (com.odysseusinc.arachne.portal.model.solr.SolrException)5 IOException (java.io.IOException)5 SolrServerException (org.apache.solr.client.solrj.SolrServerException)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 SolrCollection (com.odysseusinc.arachne.portal.model.solr.SolrCollection)2 FieldList (com.odysseusinc.arachne.portal.service.impl.solr.FieldList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 UpdateResponse (org.apache.solr.client.solrj.response.UpdateResponse)2 SolrInputDocument (org.apache.solr.common.SolrInputDocument)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BreadcrumbDTO (com.odysseusinc.arachne.portal.api.v1.dto.BreadcrumbDTO)1 SolrFieldExtractor (com.odysseusinc.arachne.portal.api.v1.dto.converters.SolrFieldExtractor)1 TenantContext (com.odysseusinc.arachne.portal.config.tenancy.TenantContext)1 SolrEntity (com.odysseusinc.arachne.portal.model.solr.SolrEntity)1 SolrFieldAnno (com.odysseusinc.arachne.portal.model.solr.SolrFieldAnno)1 SolrValue (com.odysseusinc.arachne.portal.model.solr.SolrValue)1 BaseSolrService (com.odysseusinc.arachne.portal.service.BaseSolrService)1 BreadcrumbService (com.odysseusinc.arachne.portal.service.BreadcrumbService)1 Breadcrumb (com.odysseusinc.arachne.portal.service.impl.breadcrumb.Breadcrumb)1