Sorry, but you need to ask this on the Lucene user list.
-- Jack Krupansky
-----Original Message-----
From: algebra
Sent: Friday, December 28, 2012 6:49 PM
To: dev@lucene.apache.org
Subject: get a Word in FuzzyQuery
Hello guys. I'm working with FuzzyQuery and I a have a doubt: I would like
the lucene, return to me the correct word instead of me returning the
document, for example:
query = Brazil
document = "Brazil is a big country"
with this code:
[code]
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
Directory directory = new RAMDirectory();
IndexWriter iwriter = new IndexWriter(directory, analyzer, true, new
IndexWriter.MaxFieldLength(25000));
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();
IndexSearcher isearcher = new IndexSearcher(directory);
Term term = new Term("fieldname", s);
FuzzyQuery query = new FuzzyQuery(term, 0.75f, 0);
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();
for (int i = 0 ; i < listr.size() ; i++ ) {
resp.add(listr.get(i));//melhorar método para fazer busca dentro de
busca
}
return resp;
[/code]
The lucene, return to me the entire document ie "Brazil is a big country",
but I just wanted the word "Brazil". Somebody can help me?
--
View this message in context:
http://lucene.472066.n3.nabble.com/get-a-Word-in-FuzzyQuery-tp4029521.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org