Hi,
I used the method MoreLikeThis (in search.similar package) of Lucene to
find similar documents, but the result is 0 documents also when I index
more times the same document. I don't understand why the search doesn't
work... Here I give you the code I used:
----------------------------------------------------------------------------
Directory indexDir = FSDirectory.getDirectory(INDEX_DIR, false);
IndexReader ir = IndexReader.open(indexDir);
IndexSearcher is = new IndexSearcher(indexDir);
MoreLikeThis mlt = new MoreLikeThis(ir);
Query query = mlt.like( *FileToSearchSimilar* );
System.out.println("The Query is: " + query);
Hits hits = is.search(query);
for (Iterator iterDoc = hits.iterator(); iterDoc.hasNext();) {
Hit hit = (Hit)iterDoc.next();
System.out.println("\n\nSimilar file: "+hit.get("path"));
}
ir.close();
is.close();
-----------------------------------------------------------------------------
Note that:
1) *FindToSearchSimilar* is a File i passed to MoreLikeThis
2) The index alredy contains *FileToSearchSimilar* (I previously indexed
more times the file)
3) The System.out.println("The Query is :" + query) print an empty query.
In the beginning I thought that the reason was I indexed field of files
without Field.TermVector.YES, but after I added a field (the same for
every doc) for each document in the index with this option, but nothing...
Sincerly I can't find the reason why MoreLikeThis doesn't work... I hope
someone have a suggestion or a solution.
Thanks in advance
Davide.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]