I have a task to parse all documents in a solr index. I use Lucene
IndexReader to read the index and go through each field from all documents.
However, for float or int dynamic fields, the stringValue() call always
returns some special characters. I tried tokenStreamValue, byteValue,
readerValue, and they return null.
Following is my method to parse the solr index. My question is, how can I
get the values from non-string dynamic fields properly?

    public static void main(String[] args) throws Exception {
        IndexReader reader =
IndexReader.open("/path/to/my/index/directory");

        int total = reader.numDocs();
        System.out.println("Total documents: " + total);

        for (int i = 0; i < 1; i++) {
            Document d = reader.document(i);

            List<Field> fields = d.getFields();

            for (Field f : fields) {
                String name = f.name();
                String val = f.stringValue();

               System.out.println("get field / value: [" + name + "=" + val
+ "]");            }
        }

        reader.close();
    }

Reply via email to