2
votes

dear programmers!
I have a question for the people who worked with Apache Lucene.
What better way to index the array of data in Lucene?
I use

arr [i] = Field: "arr." + i + ".data"

Java Code:

Field field = new StringField(
                "arr." + i + ".data",
                arr[i], Field.Store.YES);
doc.add(field);
1
It depends entirely on how you want to search for it :) Please tell us how you want to use it in search.Rob Audenaerde
I use, in addition, arr.size ... But I do not know how to look for it, so I'm asking ...DmitriySidyakin
Why you are saving arr. and .data in the first place?Chiron
Can i save different values in fields with the one name in the single document?DmitriySidyakin
Have a look at MultiValued fields.Chiron

1 Answers

10
votes

This is the recommend way to do it. You can then search across all the values.

for (int i=0; i<arr.length; i++ {
    Field field = new StringField("field_name", arr[i], Field.Store.YES);
    doc.add(field);
}