开发者

How to get value of a field?

开发者 https://www.devze.com 2023-03-04 11:55 出处:网络
I\'m having two fields \"name\" and \"price\".I want to get its value.Consider, name:Baseball and price:100.

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消