Creating Documents
We will create a list of documents, where each document has a single field, text
.
We use the TextField
type to indicate that it’s a “full text” field, to be split into individual tokens
during indexing.
In order to retrieve the original field value in our search results, we indicate that we want the field value
stored using Field.Store.YES
.
private static List<List<IndexableField>> createDocuments() {
List<float[]> vectors = List.of(
new float[] {1, 2, 3},
new float[] {4, 5, 6},
new float[] {7, 8, 9},
new float[] {10, 11, 12}
);
List<List<IndexableField>> docs = new ArrayList<>();
int i = 0;
for (float[] vector : vectors) {
List<IndexableField> doc = new ArrayList<>();
doc.add(new StringField("id", Integer.toString(i), Field.Store.YES));