开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜