lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@lucene.com>
Subject Re: Add Document constructor?
Date Mon, 29 Sep 2003 21:02:24 GMT
Erik Hatcher wrote:
> Are there any objections to adding a constructor to Document to take a 
> Field[]?
> 
> It would make test code a lot cleaner at least:
> 
>     Document doc = new Document();
>     doc.add(Field.Text("contents", "fuzzy"));
>     writer.addDocument(doc);
>     doc = new Document();
>     doc.add(Field.Text("contents", "wuzzy"));
>     writer.addDocument(doc);
> 
> reduced to:
> 
>     writer.addDocument(new Document(new Field[] {Field.Text("contents", 
> "fuzzy"),
>                                                 Field.Text("contents", 
> "wuzzy")}));

You're over stating your case a bit.  This is only equivalent to:

   Document doc = new Document();
   doc.add(Field.Text("contents", "fuzzy"));
   doc.add(Field.Text("contents", "wuzzy"));
   writer.addDocument(doc);

And, your reduced example, if formatted within 80 columns, would 
probably really require three lines, not two.  So you've saved but a line.

That's not enough for me to motivate the change, but I don't object 
strongly.

Doug


Mime
View raw message