FAQ
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:
writer.addDocument(doc1);
writer.addDocument(doc2);

then create a query from the doc2 :
IndexReader ir=IndexReader.open(directory);
MoreLikeThis mlt=new MoreLikeThis(ir);
Query query=mlt.like(1);
and then search the query:
IndexSearcher searcher=new IndexSearcher(directory);
ScoreDoc[] scoreDocs=searcher.search(query,5);

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?
thanks.
Kamal
--

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedMay 4, '09 at 11:35a
activeMay 4, '09 at 11:35a
posts1
users1
websitelucene.apache.org

1 user in discussion

Kamal Najib: 1 post

People

Translate

site design / logo © 2022 Grokbase