lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davide <davidi...@libero.it>
Subject Problem finding similar documents with MoreLikeThis method.
Date Wed, 19 Jul 2006 08:40:31 GMT
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message