/** * Delegator.<p> * * @return the spellcheck response */ public SpellCheckResponse getSpellCheckResponse() { return m_queryResponse.getSpellCheckResponse(); }
static Map<String, List<Alternative>> extreactSuggestions(QueryResponse response) { if (response == null || response.getSpellCheckResponse() == null || response.getSpellCheckResponse().getSuggestions() == null) { return Collections.emptyMap(); } Map<String, List<Alternative>> alternativesMap = new LinkedHashMap<>(); SpellCheckResponse scr = response.getSpellCheckResponse(); if (scr != null && scr.getSuggestions() != null) { for (SpellCheckResponse.Suggestion suggestion : scr.getSuggestions()) { List<Alternative> alternatives = new ArrayList<>(); if (!CollectionUtils.isEmpty(suggestion.getAlternatives())) { for (int i = 0; i < suggestion.getAlternatives().size(); i++) { alternatives.add(new Alternative(suggestion.getToken(), suggestion.getOriginalFrequency(), suggestion.getAlternatives().get(i), suggestion.getAlternativeFrequencies().get(i))); } } alternativesMap.put(suggestion.getToken(), alternatives); } } return alternativesMap; }
SolrServer solr = new CommonsHttpSolrServer("http://localhost:8080/solr"); ModifiableSolrParams params = new ModifiableSolrParams(); params.set("qt", "/spell"); params.set("q", "whatever"); params.set("spellcheck", "on"); //params.set("spellcheck.build", "true"); QueryResponse response = solr.query(params); SpellCheckResponse spellCheckResponse = response.getSpellCheckResponse(); if (!spellCheckResponse.isCorrectlySpelled()) { for (Suggestion suggestion : response.getSpellCheckResponse().getSuggestions()) { logger.debug("original token: " + suggestion.getToken() + " - alternatives: " + suggestion.getAlternatives()); } }
final String collation = response.getSpellCheckResponse() != null ? response.getSpellCheckResponse().getCollatedResult().replaceFirst("\\*$","") : null;
QueryResponse response = this.externalServicesAccess.getServer().query(enhancedParams); SolrDocumentList results = response.getResults(); if (response.getSpellCheckResponse() != null && !response.getSpellCheckResponse().isCorrectlySpelled() && StringUtils.isNotEmpty(response.getSpellCheckResponse().getCollatedResult())) { enhancedParams = SolrQueryUtils.applySpellcheckSuggestion(enhancedParams, response.getSpellCheckResponse() .getCollatedResult()); SolrDocumentList spellcheckResults =
QueryResponse response = this.externalServicesAccess.getSolrConnection(this).query(query); SolrDocumentList results = response.getResults(); if (response.getSpellCheckResponse() != null && !response.getSpellCheckResponse().isCorrectlySpelled() && StringUtils.isNotEmpty(response.getSpellCheckResponse().getCollatedResult())) { SolrQueryUtils.applySpellcheckSuggestion(query, response.getSpellCheckResponse().getCollatedResult()); this.logger.debug("Searching [{}] with spellchecked query [{}]", this.getIdentifier(), query); SolrDocumentList spellcheckResults =
if (response.getSpellCheckResponse() != null && !response.getSpellCheckResponse().isCorrectlySpelled()) { String suggestedQuery = response.getSpellCheckResponse().getCollatedResult(); if (StringUtils.isEmpty(suggestedQuery)) { return results;
return qres.getSpellCheckResponse(); } catch (Exception e) { LOG.debug("Exception while performing spellcheck query...", e);
SpellCheckResponse spellCheckResponse = queryResponse.getSpellCheckResponse(); if (spellCheckResponse != null && spellCheckResponse.getSuggestions() != null && spellCheckResponse.getSuggestions().size() > 0) {
SpellCheckResponse spellCheckResponse = queryResponse.getSpellCheckResponse(); if (spellCheckResponse != null && spellCheckResponse.getSuggestions() != null && spellCheckResponse.getSuggestions().size() > 0) {
if (solrQueryResponse.getSpellCheckResponse() != null) { String recommendedQuery = solrQueryResponse.getSpellCheckResponse().getCollatedResult(); if (StringUtils.isNotBlank(recommendedQuery)) { result.setSpellCheckQuery(recommendedQuery);
@Override public SuggestionResults fetchSuggections(final SolrIndex<FulltextIndexSchema> index, final String query) { SolrQuery params = new SolrQuery(); params.set(PARAM_QT, "/suggest"); params.set(PARAM_QUERY, query); params.set(PARAM_SPELLCHECK, "true"); QueryResponse response = null; try { response = index.query(params); } catch (final SearchParserException spe) { log.debug("Error in query {}", query, spe); throw new SearchException("Error in query " + query, spe); } final SpellCheckResponse spellCheckResponse = response.getSpellCheckResponse(); if (spellCheckResponse == null) { return new SuggestionResults(); } final Suggestion suggestion = spellCheckResponse.getSuggestion(query); if (suggestion == null) { return new SuggestionResults(); } List<SuggestionResult> alternatives = new ArrayList<SuggestionResult>(); for (String token : suggestion.getAlternatives()) { alternatives.add(new SuggestionResult(token)); } return new SuggestionResults(suggestion.getNumFound(), suggestion.getOriginalFrequency(), alternatives); }
SpellCheckResponse spellCheckResponse = queryResponse.getSpellCheckResponse(); if (spellCheckResponse != null) { List<SpellCheckResponse.Suggestion> suggestions = spellCheckResponse.getSuggestions();