> It should be possible to randomly add and delete such relationships after
> indexWriter.addDocument(), is that the idea?


Yes. A "like" action may, for example allow me to tag an existing document by 
connecting 2 documents - my personal "like" document and a document with 
content of interest.
   doc 1   = [user:mark       tag:like]
   doc 56 = [title:Lucene    body:Lucene is a search library...]

I then call:
   indexWriter.addLink(1,56)

If this was my first "Like" then I may need to contemplate using a variation of 
the above API that allows a yet-to-be-committed "Document" object in place of 
the doc ids.


> Adding such relationships by docId would need the addition of
> a separate (from the segments) index structure


Yes, I need to think about the detail of file structures next. For now I'm 
sticking with thinking about user API and functionality and assuming we can 
maintain cross-segment docid references that get updated somehow at merge time.

> 
> 
> Would each link also have an attribute (think payload)?

I was thinking if attributes are needed (e.g. a star rating on my document 
"like" example) then this could be catered for with a document e.g. rather than 
linking the single doc [user:mark tag:like] to all my liked docs I could create 
specific doc instances of [user:mark rating:5 tag:like] and linking via that. 


> Would such relationships be named (sth like foreign key field names)?

For now I was thinking of storing simple docid->docid links.

Once we have these links we could do some funky things:
{pseudo code:}
       //My fave docs from last week
       int myLikesDocId=searchForLuceneDocWithUserNameAndTag("mark", "like");
       DocIdSet myLikedDocs =indexReader.getOutboundLinks(myLikesDocId)
       searcher.search(lastWeekRangeQuery, new Filter(myLikedDocs));

      //Other users who share my interests
      DocIdSet usersWhoLikeWhatILike = indexReader.getInboundLinks(myLikedDocs);


Cheers
Mark

Reply via email to