Package org.apache.solr.spelling

Examples of org.apache.solr.spelling.SpellingResult


    LOG.debug("getSuggestions: " + options.tokens);
    if (lookup == null) {
      LOG.info("Lookup is null - invoke spellchecker.build first");
      return EMPTY_RESULT;
    }
    SpellingResult res = new SpellingResult();
    for (Token t : options.tokens) {
      String term = new String(t.buffer(), 0, t.length());
      List<LookupResult> suggestions = lookup.lookup(term,
          options.onlyMorePopular, options.count);
      if (suggestions == null) {
        continue;
      }
      if (!options.onlyMorePopular) {
        Collections.sort(suggestions);
      }
      for (LookupResult lr : suggestions) {
        res.add(t, lr.key, ((Number)lr.value).intValue());
      }
    }
    return res;
  }
View Full Code Here


  }

  @Override
  public SpellingResult getSuggestions(SpellingOptions options) throws IOException {

    SpellingResult result = new SpellingResult();
    //just spit back out the results
    Iterator<String> iterator = options.customParams.getParameterNamesIterator();
    int i = 0;
    while (iterator.hasNext()){
      String name = iterator.next();
      String value = options.customParams.get(name);
      result.add(new Token(name, i++, i++),  Collections.singletonList(value));
    }   
    return result;
  }
View Full Code Here

    LOG.debug("getSuggestions: " + options.tokens);
    if (lookup == null) {
      LOG.info("Lookup is null - invoke spellchecker.build first");
      return EMPTY_RESULT;
    }
    SpellingResult res = new SpellingResult();
    for (Token t : options.tokens) {
      String term = new String(t.buffer(), 0, t.length());
      List<LookupResult> suggestions = lookup.lookup(term,
          options.onlyMorePopular, options.count);
      if (suggestions == null) {
        continue;
      }
      if (!options.onlyMorePopular) {
        Collections.sort(suggestions);
      }
      for (LookupResult lr : suggestions) {
        res.add(t, lr.key, ((Number)lr.value).intValue());
      }
    }
    return res;
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.spelling.SpellingResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.