Document doc = new Document();
Field idField = newStringField(random, "id", "", Field.Store.NO);
Field binaryDVField = null;
Field numericDVField = null;
Field sortedDVField = null;
Field sortedSetDVField = new SortedSetDocValuesField("sortedsetdv", new BytesRef());
doc.add(idField);
doc.add(newField(random, "field", "some text contents", storedTextType));
if (defaultCodecSupportsDocValues()) {
binaryDVField = new BinaryDocValuesField("binarydv", new BytesRef());
numericDVField = new NumericDocValuesField("numericdv", 0);
sortedDVField = new SortedDocValuesField("sorteddv", new BytesRef());
doc.add(binaryDVField);
doc.add(numericDVField);
doc.add(sortedDVField);
}
if (defaultCodecSupportsSortedSet()) {
doc.add(sortedSetDVField);
}
for(int i=0;i<100;i++) {
idField.setStringValue(Integer.toString(i));
if (defaultCodecSupportsDocValues()) {
binaryDVField.setBytesValue(new BytesRef(idField.stringValue()));
numericDVField.setLongValue(i);
sortedDVField.setBytesValue(new BytesRef(idField.stringValue()));
}
sortedSetDVField.setBytesValue(new BytesRef(idField.stringValue()));
int action = random.nextInt(100);
if (action == 17) {
w.addIndexes(adder);
} else if (action%30 == 0) {
w.deleteAll();