lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <markharw...@yahoo.co.uk>
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".

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


Cheers
Mark

----- Original Message ----
From: Davide <davidin81@libero.it>
To: java-user@lucene.apache.org
Sent: Wednesday, 19 July, 2006 9:40:31 AM
Subject: Problem finding similar documents with MoreLikeThis method.

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





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