/** * Gets a connection to the targeted core, used for sending the schema requests. * * @return a valid solr client */ protected SolrClient getClient() { return this.coreConnection.getSolrConnection(getTargetVocabularyId()); }
this.externalServicesAccess.createReplacementCore(this); try { for (VocabularyExtension ext : this.extensions.get()) { this.externalServicesAccess.replaceCore(this); this.externalServicesAccess.getTermCache(this).removeAll(); this.logger.warn("Failed to reindex. {}", ex.getMessage()); } finally { this.externalServicesAccess.discardReplacementCore(this);
/** * Commits the batch of newly-processed documents. */ protected void commitTerms(Collection<SolrInputDocument> batch) throws SolrServerException, IOException, OutOfMemoryError { this.externalServicesAccess.getReplacementSolrConnection(this).add(batch); this.externalServicesAccess.getReplacementSolrConnection(this).commit(); }
private VocabularyTerm cacheTerm(String id, SolrDocument doc) { Cache<VocabularyTerm> cache = this.externalServicesAccess.getTermCache(this); VocabularyTerm term = cache.get(id); if (term == null) { term = new SolrVocabularyTerm(doc, this); cache.set(id, term); } return term; } }
Cache<VocabularyTerm> cache = this.externalServicesAccess.getTermCache(this); for (String id : ids) { VocabularyTerm cachedTerm = cache.get(id);
/** * Delete all the data in the Solr index. * * @return {@code 0} if the command was successful, {@code 1} otherwise */ protected int clear() { try { this.externalServicesAccess.getSolrConnection(this).deleteByQuery("*:*"); return 0; } catch (SolrServerException ex) { this.logger.error("SolrServerException while clearing the Solr index", ex); } catch (IOException ex) { this.logger.error("IOException while clearing the Solr index", ex); } return 1; }
@Override public VocabularyTerm getTerm(String id) { if (StringUtils.isBlank(id)) { return null; } VocabularyTerm result = this.externalServicesAccess.getTermCache(this).get(id); if (result == null) { SolrQuery query = new SolrQuery(ID_FIELD_NAME + ':' + ClientUtils.escapeQueryChars(id)); SolrDocumentList allResults = this.search(query); if (allResults != null && !allResults.isEmpty()) { result = new SolrVocabularyTerm(allResults.get(0), this); this.externalServicesAccess.getTermCache(this).set(id, result); } else { this.externalServicesAccess.getTermCache(this).set(id, EMPTY_MARKER); } } return (result == EMPTY_MARKER) ? null : result; }
/** * Sets the ontology version data. * * @param doc the Solr input document * @param ontModel the ontology model * @throws IOException if failed to communicate with Solr server while indexing ontology * @throws SolrServerException if failed to index ontology */ private void setVersion(@Nonnull final SolrInputDocument doc, @Nonnull final OntModel ontModel) throws IOException, SolrServerException { final String version = ontModel.getOntology(getBaseOntologyUri()).getVersionInfo(); if (StringUtils.isNotBlank(version)) { doc.addField(ID_FIELD_NAME, HEADER_INFO_LABEL); doc.addField(VERSION_FIELD_NAME, version); this.externalServicesAccess.getReplacementSolrConnection(this).add(doc); doc.clear(); } }
/** * Delete all the data in the Solr index. * * @return {@code 0} if the command was successful, {@code 1} otherwise */ protected int clear() { try { this.externalServicesAccess.getSolrConnection(this).deleteByQuery("*:*"); return 0; } catch (SolrServerException ex) { this.logger.error("SolrServerException while clearing the Solr index", ex); } catch (IOException ex) { this.logger.error("IOException while clearing the Solr index", ex); } return 1; }
/** * Delete all the data in the Solr index. * * @return {@code 0} if the command was successful, {@code 1} otherwise */ protected int clear() { try { this.externalServicesAccess.getSolrConnection(this).deleteByQuery("*:*"); return 0; } catch (SolrServerException ex) { this.logger.error("SolrServerException while clearing the Solr index", ex); } catch (IOException ex) { this.logger.error("IOException while clearing the Solr index", ex); } return 1; }
/** * Gets a connection to the targeted core, used for sending the schema requests. * * @return a valid solr client */ protected SolrClient getClient() { return this.coreConnection.getSolrConnection(this.vocabularyManager.getVocabulary(getTargetVocabularyId())); }
/** * Get the number of entries that match a specific Lucene query. * * @param query a valid Lucene query as string * @return the number of entries matching the query */ protected long count(String query) { SolrQuery params = new SolrQuery(query); params.setStart(0); params.setRows(0); SolrDocumentList results; try { this.logger.debug("Counting terms matching [{}] in [{}]", query, this.getIdentifier()); results = this.externalServicesAccess.getSolrConnection(this).query(params).getResults(); return results.getNumFound(); } catch (Exception ex) { this.logger.error("Failed to count vocabulary terms: {}", ex.getMessage(), ex); return -1; } }
@Override public String getVersion() { QueryResponse response; SolrQuery query = new SolrQuery(); SolrDocumentList termList; SolrDocument firstDoc; query.setQuery("version:*"); query.set(CommonParams.ROWS, "1"); try { response = this.externalServicesAccess.getSolrConnection(this).query(query); termList = response.getResults(); if (!termList.isEmpty()) { firstDoc = termList.get(0); return firstDoc.getFieldValue(VERSION_FIELD_NAME).toString(); } } catch (SolrServerException | SolrException ex) { this.logger.warn("Failed to query vocabulary version: {}", ex.getMessage()); } catch (IOException ex) { this.logger.error("IOException while getting vocabulary version", ex); } return null; } }
@Override public String getVersion() { final SolrQuery query = new SolrQuery(); query.setQuery("version:*"); query.set(CommonParams.ROWS, "1"); try { final QueryResponse response = this.externalServicesAccess.getSolrConnection(this).query(query); final SolrDocumentList termList = response.getResults(); if (!termList.isEmpty()) { final SolrDocument firstDoc = termList.get(0); return firstDoc.getFieldValue(VERSION_FIELD_NAME).toString(); } } catch (SolrServerException | SolrException | IOException ex) { this.logger.warn("Failed to query ontology version: {}", ex.getMessage()); } return null; }
@Override public String getVersion() { QueryResponse response; SolrQuery query = new SolrQuery(); SolrDocumentList termList; SolrDocument firstDoc; query.setQuery("version:*"); query.set("rows", "1"); try { response = this.externalServicesAccess.getSolrConnection(this).query(query); termList = response.getResults(); if (!termList.isEmpty()) { firstDoc = termList.get(0); return firstDoc.getFieldValue(VERSION_FIELD_NAME).toString(); } } catch (SolrServerException | SolrException | IOException ex) { this.logger.warn("Failed to query vocabulary version: {}", ex.getMessage()); } return null; } }
protected VocabularyTerm requestTerm(String queryString, String phraseFields) { QueryResponse response; SolrQuery query = new SolrQuery(); SolrDocumentList termList; VocabularyTerm term; query.setQuery(queryString); query.setRows(1); if (phraseFields != null) { query.set(DisMaxParams.PF, phraseFields); } try { response = this.externalServicesAccess.getSolrConnection(this).query(query); termList = response.getResults(); if (termList != null && !termList.isEmpty()) { term = new SolrVocabularyTerm(termList.get(0), this); return term; } } catch (SolrServerException | SolrException ex) { this.logger.warn("Failed to query vocabulary term: {} ", ex.getMessage()); } catch (IOException ex) { this.logger.error("IOException while getting vocabulary term ", ex); } return null; }
List<SuggestedPhenotype> result = new LinkedList<>(); try { response = this.solrManager.getSolrConnection(this.omim).query(prepareParams(phenotypes, nphenotypes)); } catch (SolrServerException | IOException ex) { this.logger.warn("Failed to query OMIM index: {}", ex.getMessage());
QueryResponse response = this.externalServicesAccess.getSolrConnection(this).query(query); SolrDocumentList results = response.getResults(); if (response.getSpellCheckResponse() != null && !response.getSpellCheckResponse().isCorrectlySpelled() this.logger.debug("Searching [{}] with spellchecked query [{}]", this.getIdentifier(), query); SolrDocumentList spellcheckResults = this.externalServicesAccess.getSolrConnection(this).query(query).getResults(); if (results.getMaxScore() < spellcheckResults.getMaxScore()) { results = spellcheckResults;