You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Steve Pruitt <bp...@opentext.com> on 2017/09/06 20:09:13 UTC

NumberFormatException for multvalue, pint

Can't get a multi-valued pint field to update.

The schema defines the field:  <field name="dnis" type="pints" multiValued="true" required="false" docValues="true" stored="true"/>

I get the exception on this input:  <field name="dnis">7780386,7313483</field>

Caused by: java.lang.NumberFormatException: For input string: "7780386, 7313483"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at org.apache.solr.schema.IntPointField.createField(IntPointField.java:181)
	at org.apache.solr.schema.PointField.createFields(PointField.java:216)
	at org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:72)
	at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:179)

Not sure why the parser thinks the values are strings.  I don't see any non-numeric extraneous characters.

Do I need docValues and multivalued in my field definition, since they are defined on the pints field type?

Thanks.

-Steve

Re: NumberFormatException for multvalue, pint

Posted by Yonik Seeley <ys...@gmail.com>.
On Wed, Sep 6, 2017 at 4:09 PM, Steve Pruitt <bp...@opentext.com> wrote:
> Can't get a multi-valued pint field to update.
>
> The schema defines the field:  <field name="dnis" type="pints" multiValued="true" required="false" docValues="true" stored="true"/>
>
> I get the exception on this input:  <field name="dnis">7780386,7313483</field>
>
> Caused by: java.lang.NumberFormatException: For input string: "7780386, 7313483"

Try two separate values:
 <field name="dnis">7780386</field>
 <field name="dnis">7313483</field>

Or in JSON you can do: dnis:[7780386,7313483]

-Yonik


>         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
>         at java.lang.Integer.parseInt(Integer.java:580)
>         at java.lang.Integer.parseInt(Integer.java:615)
>         at org.apache.solr.schema.IntPointField.createField(IntPointField.java:181)
>         at org.apache.solr.schema.PointField.createFields(PointField.java:216)
>         at org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:72)
>         at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:179)
>
> Not sure why the parser thinks the values are strings.  I don't see any non-numeric extraneous characters.
>
> Do I need docValues and multivalued in my field definition, since they are defined on the pints field type?
>
> Thanks.
>
> -Steve

RE: [EXTERNAL] - Re: NumberFormatException for multvalue, pint

Posted by Steve Pruitt <bp...@opentext.com>.
Sigh.  You are right and thank you for pointing out the obvious, much to my chagrin.  :>)

Again, thanks.

-S

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: Wednesday, September 06, 2017 4:42 PM
To: solr-user
Subject: [EXTERNAL] - Re: NumberFormatException for multvalue, pint

You're making a common mistake as to the meaning of multiValued. The input doc should look something like (xml format)

<add>
  <doc>
     <field name="mv_int_field">1</field>
    <field name="mv_int_field">2</field>
  </doc>
</add>

Each "mv_int_field" is a separate, complete single integer. But there can be a many of them.

when you specify
   <field name="mv_int_field">1,2,3</field>

you're telling Solr that the _single_ value of the field is "1,2,3"
which, of course, doesn't parse as an integer.

Best,
Erick



On Wed, Sep 6, 2017 at 1:09 PM, Steve Pruitt <bp...@opentext.com> wrote:
> Can't get a multi-valued pint field to update.
>
> The schema defines the field:  <field name="dnis" type="pints" 
> multiValued="true" required="false" docValues="true" stored="true"/>
>
> I get the exception on this input:  <field 
> name="dnis">7780386,7313483</field>
>
> Caused by: java.lang.NumberFormatException: For input string: "7780386, 7313483"
>         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
>         at java.lang.Integer.parseInt(Integer.java:580)
>         at java.lang.Integer.parseInt(Integer.java:615)
>         at org.apache.solr.schema.IntPointField.createField(IntPointField.java:181)
>         at org.apache.solr.schema.PointField.createFields(PointField.java:216)
>         at org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:72)
>         at 
> org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java
> :179)
>
> Not sure why the parser thinks the values are strings.  I don't see any non-numeric extraneous characters.
>
> Do I need docValues and multivalued in my field definition, since they are defined on the pints field type?
>
> Thanks.
>
> -Steve

Re: NumberFormatException for multvalue, pint

Posted by Erick Erickson <er...@gmail.com>.
You're making a common mistake as to the meaning of multiValued. The
input doc should look something like (xml format)

<add>
  <doc>
     <field name="mv_int_field">1</field>
    <field name="mv_int_field">2</field>
  </doc>
</add>

Each "mv_int_field" is a separate, complete single integer. But there
can be a many of them.

when you specify
   <field name="mv_int_field">1,2,3</field>

you're telling Solr that the _single_ value of the field is "1,2,3"
which, of course, doesn't parse as an integer.

Best,
Erick



On Wed, Sep 6, 2017 at 1:09 PM, Steve Pruitt <bp...@opentext.com> wrote:
> Can't get a multi-valued pint field to update.
>
> The schema defines the field:  <field name="dnis" type="pints" multiValued="true" required="false" docValues="true" stored="true"/>
>
> I get the exception on this input:  <field name="dnis">7780386,7313483</field>
>
> Caused by: java.lang.NumberFormatException: For input string: "7780386, 7313483"
>         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
>         at java.lang.Integer.parseInt(Integer.java:580)
>         at java.lang.Integer.parseInt(Integer.java:615)
>         at org.apache.solr.schema.IntPointField.createField(IntPointField.java:181)
>         at org.apache.solr.schema.PointField.createFields(PointField.java:216)
>         at org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:72)
>         at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:179)
>
> Not sure why the parser thinks the values are strings.  I don't see any non-numeric extraneous characters.
>
> Do I need docValues and multivalued in my field definition, since they are defined on the pints field type?
>
> Thanks.
>
> -Steve