lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <>
Subject Re: Problem finding similar documents with MoreLikeThis method.
Date Wed, 19 Jul 2006 09:22:36 GMT
Looks like the class defaults to only searching a field called "contents".

a) call setFieldNames() with null to force the class to use a list of all indexed fields derived
from your IndexReader
b) call setFieldNames() with the explicit shortlist of field names you want to match on


----- Original Message ----
From: Davide <>
Sent: Wednesday, 19 July, 2006 9:40:31 AM
Subject: Problem finding similar documents with MoreLikeThis method.

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 =;

IndexSearcher is = new IndexSearcher(indexDir);
MoreLikeThis mlt = new MoreLikeThis(ir);

Query query = *FileToSearchSimilar* );
System.out.println("The Query is: " + query);
Hits hits =;
for (Iterator iterDoc = hits.iterator(); iterDoc.hasNext();) {
    Hit hit = (Hit);
    System.out.println("\n\nSimilar file: "+hit.get("path"));

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

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message