Creating Documents
We will mostly reuse the same documents from SimpleSearch, but we’ll also add a numeric IntField
which will
write both points and doc values. Points are covered in more detail by examples in the “points” package.
To make the output mildly more interesting, let’s not add the numeric field to one of the documents.
private static List<List<IndexableField>> createDocuments() {
List<String> texts = List.of(
"The quick fox jumped over the lazy, brown dog",
"Lorem ipsum, dolor sit amet",
"She left the web, she left the loom, she made three paces through the room",
"The sly fox sneaks past the oblivious dog"
);
List<List<IndexableField>> docs = new ArrayList<>();
int i = 0;
for (String text : texts) {
List<IndexableField> doc = new ArrayList<>();
doc.add(new TextField("text", text, Field.Store.YES));
if (++i != 2) {
doc.add(new IntField("val", i, Field.Store.YES));
}
docs.add(doc);
}
return docs;
}