2.4.7 Multi-valued Fields
Suppose your documents have an author field, but sometimes theres more than one author for a document. One way to handle this would be to loop through all the authors, appending them into a single String, which you could then use to create a Lucene Field. Another, perhaps more elegant way is to just keep adding the same Field with different value, like this:
Document doc = new Document();
for (int i = 0; i < authors.length; i++)
{
doc.add(new Field("author", authors[i],
Field.Store.YES,
Field.Index.ANALYZED));
}
I think the code above doesn't reflect what the author is trying to say. Its creating additional documents instead of Multi-Valued fields. Can you verify and fix please?
Thanks!
|