I was using lucene 3.6 and my function worked well. After I changed the version of lucene to 4.0 and did some adjustments and my function is not working. Someone tell me what do you know I'm doing wrong?
public List <String> fuzzyLuceneList(List<String> list, String s) throws CorruptIndexException, LockObtainFailedException, IOException, ParseException { List<String> listr = new ArrayList<String>(); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40); Directory directory = new RAMDirectory(); IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer); IndexWriter iwriter = new IndexWriter(directory, config); Document doc; for (int i = 0; i < list.size(); i++) { doc = new Document(); doc.add(new Field("fieldname", list.get(i), Field.Store.YES, Field.Index.ANALYZED)); iwriter.addDocument(doc); } iwriter.close(); IndexReader reader = IndexReader.open(directory); IndexSearcher isearcher = new IndexSearcher(reader); Term term = new Term("fieldname", s); Query query = new FuzzyQuery(term, 1,0);// 0-2 TopScoreDocCollector collector = TopScoreDocCollector.create(10, true); isearcher.search(query, collector); ScoreDoc[] hits = collector.topDocs().scoreDocs; for (int i = 0; i < hits.length; i++) { Document hitDoc = isearcher.doc(hits[i].doc); listr.add(hitDoc.get("fieldname")); } //isearcher.close(); directory.close(); return listr; } Thanks! -- View this message in context: http://lucene.472066.n3.nabble.com/FuzzyQuery-in-lucene-4-0-tp4031871.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org