lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kamal Najib <>
Subject get the cosine similarity between two docs
Date Mon, 04 May 2009 11:34:34 GMT
Hi all, 
I try to get the cosine similarity between two docs:
I have tried first to create a document for a String like this:
Document doc1=new Document();
doc1.add(new Field("term","nodular lesions over years responding kamal najib nodular lesions
over years responding",Field.Store.YES,Field.Index.TOKENIZED));
Document doc2=new Document();
doc2.add(new Field("term","we describe 5 cases( kamal najib , 61 years old )",Field.Store.YES,Field.Index.TOKENIZED));
than add the both docs to an indexWriter:

then create a query from the doc2 :
MoreLikeThis mlt=new MoreLikeThis(ir);
and then search the query:
IndexSearcher searcher=new IndexSearcher(directory);

then the lenght of the scoreDocs array was 0.Mean that the two docs are not similar?when are
two docs similar in this apraotch?how can i check the correctness  of the similarity result?do
i do somthing wrong?

View raw message