0

I saw an example of extracting all available terms for a field here

The reason it doesn't fit my porpouses is because terms and stored values are different, e.g. stored value of "black cat" will be represnted as two terms "black" and "cat". in my code I need to extract whole stored values in this case "black cat".

1 Answers1

0

Yes, you could do that. I'm not C# programmer, but hopefully you will understand Java code.

        IndexReader reader = DirectoryReader.open(dir);

        final int len = reader.maxDoc();
        for (int i = 0; i < len; ++i) {
            Document document = reader.document(i);
            List<IndexableField> fields = document.getFields();
            for (IndexableField field : fields) {
                if (field.fieldType().stored()) {
                    System.out.println(field.stringValue());
                }
            }
        }

So, basically, I'm traversing across all docs, get all fields, and if they are stored, get the data. You could filter it by the name of the field, that are needed for you.

Full test could be found here - https://raw.githubusercontent.com/MysterionRise/information-retrieval-adventure/master/src/main/java/org/mystic/GetAllStoredFieldValues.java (also with the proof, that it works correctly)

Mysterion
  • 9,050
  • 3
  • 30
  • 52