/** * 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.getServer().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 String getVersion() { QueryResponse response; SolrQuery query = new SolrQuery(); SolrDocumentList termList; SolrDocument firstDoc; query.setQuery("version:*"); query.set("rows", "1"); try { response = this.externalServicesAccess.getServer().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 ontology version: {}", ex.getMessage()); } return null; } }
/** * Get the number of entries that match a specific Lucene query. * * @param query a valid the Lucene query as string * @return the number of entries matching the query */ protected long count(String query) { ModifiableSolrParams params = new ModifiableSolrParams(); params.set(CommonParams.Q, query); params.set(CommonParams.START, "0"); params.set(CommonParams.ROWS, "0"); SolrDocumentList results; try { results = this.externalServicesAccess.getServer().query(params).getResults(); return results.getNumFound(); } catch (Exception ex) { this.logger.error("Failed to count ontology terms: {}", ex.getMessage(), ex); return 0; } }
QueryResponse response = this.externalServicesAccess.getServer().query(enhancedParams); SolrDocumentList results = response.getResults(); if (response.getSpellCheckResponse() != null && !response.getSpellCheckResponse().isCorrectlySpelled() .getCollatedResult()); SolrDocumentList spellcheckResults = this.externalServicesAccess.getServer().query(enhancedParams).getResults(); if (results.getMaxScore() < spellcheckResults.getMaxScore()) { results = spellcheckResults;