How to get value of a field?
I'm having two fields "name" and "price".I want to get its value.Consider, name:Baseball and price:100.
Baseball is of type string and 100 is int. I'm using the following code to get the value:
Field inputfield =docu.getField("name");
inputfield.stringValue(); //Output:Baseball (working)
Similarly, to 开发者_Python百科get integer value (i.e 100) what i've to do?
Thanks, Marshal
All fields in Lucene are String values, you will have to do a Integer.parseInt() or equal for number fields.
Use getFieldValue
and casting:
Integer val = (Integer)docu.getFieldValue("myvar");
精彩评论