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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations