lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Lucene SpellChecker returns no suggetions after changing Server
Date Sat, 20 Dec 2008 18:24:21 GMT
: How can I speed it up?

don't construct a new LuceneDictionary/IndexReader on every "suggest" call 
... construct them once, and reuse them for each suggestion.

: My temporary method:
: public static Vector suggest(String query, String indexName, String field,
: float accuracy) {
: 		Vector v = new Vector();
: 		String[] suggestions = null;
: 		
: 		try {
: 			SpellChecker spellchecker = new SpellChecker(new RAMDirectory()/*, new
: JaroWinklerDistance()*/);			
: 			spellchecker.indexDictionary(new
: LuceneDictionary(IndexReader.open(indexName), field));
: 			spellchecker.setAccuracy(accuracy);			
: 			suggestions = spellchecker.suggestSimilar(query, 5);
: 		} catch (Exception e) {}
: 		
: 		for(int i = 0; i < suggestions.length; i++) {
: 			v.add(suggestions[i]);
: 		}
: 		
: 		return v;
: }


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message