for(int i=0;i<50;i++)
b[i] = (byte) (i+77);
Document doc = new Document();
Field f = new Field("binary", b, 10, 17, Field.Store.YES);
f.setTokenStream(new WhitespaceTokenizer(new StringReader("doc1field1")));
Field f2 = new Field("string", "value", Field.Store.YES,Field.Index.ANALYZED);
f2.setTokenStream(new WhitespaceTokenizer(new StringReader("doc1field2")));
doc.add(f);
doc.add(f2);
w.addDocument(doc);
// add 2 docs to test in-memory merging
f.setTokenStream(new WhitespaceTokenizer(new StringReader("doc2field1")));
f2.setTokenStream(new WhitespaceTokenizer(new StringReader("doc2field2")));
w.addDocument(doc);
// force segment flush so we can force a segment merge with doc3 later.
w.commit();
f.setTokenStream(new WhitespaceTokenizer(new StringReader("doc3field1")));
f2.setTokenStream(new WhitespaceTokenizer(new StringReader("doc3field2")));
w.addDocument(doc);
w.commit();
w.optimize(); // force segment merge.