0

Assume I have a list of objects that look like this:

class AuctionItem
{
  string Name {get;set;}
  byte[] Image {get;set;}
}

and I want to store them in a Lucene Document like so:

foreach(var auctionItem in AuctionItems)
{
  doc.Add(new Field("Name", ... ) );
  doc.Add(new Field("Image", ... ) );
}

When querying the index, I want to ensure that I get one or more documents back where the Name field is grouped together with the Image field since the Name is related to the Image.

enter image description here

Is there a way to do this with Lucene?

sduplooy
  • 14,340
  • 9
  • 41
  • 60
  • You want to group documents with the same name? Documents with same image? The question is a bit confusing. – Felipe Hummel Dec 31 '11 at 21:15
  • Each Document contains multiple instances of AuctionItem. When a single Document is returned by some query, I need to have the Name field associated with the Image field. Now, if there are multiple Names and multiple Images, how do I know which Image goes with which Name? – sduplooy Jan 01 '12 at 06:24
  • You will not be able to do what you want if you add various auctionitens to the same document. When you add a field multiple times, lucene just appends them together: http://docjar.org/docs/api/org/apache/lucene/document/Document.html#add(Fieldable). Why can't you put each auctioniten in a different lucene document? – Felipe Hummel Jan 01 '12 at 16:42

0 Answers0