Randall Coding
Randall Coding

Reputation: 483

Solr IOException on spanish characters (films example)

Specs: Solr 7.7.1. Ubuntu Linux 18.04.

I've been following this tutorial https://www.youtube.com/watch?v=5gPhZm9XzAY&feature=youtu.be to simply create a solr core and post data from the films example packaged with Solr.

I used the command bin/post -c films example/films/films.xml and received the following error on about the 6th document.

<str name="msg">ERROR: [doc=/en/quien_es_el_senor_lopez] Error adding field 'name'='¿Quién es el señor López?' msg=For input string: "¿Quién es el señor López?"</str>
  <int name="code">400</int>
</lst>
</response>
SimplePostTool: WARNING: IOException while reading response: java.io.IOException: Server returned HTTP response code: 400 for URL: http://localhost:8983/solr/films/update

Is this related to the Spanish language characters? This seems odd since this is a pre-packaged Solr example and works in the tutorial. Could there be something wrong with my setup?

edit* The errors in the solr log are the following

2019-03-16 14:21:32.097 INFO  (qtp802600647-22) [   x:films] o.a.s.s.ManagedIndexSchema Upgraded to managed schema at /home/mcgoy/solr-7.7.1/server/solr/films/conf/managed-schema
2019-03-16 14:21:32.454 INFO  (qtp802600647-22) [   x:films] o.a.s.u.p.LogUpdateProcessorFactory [films]  webapp=/solr path=/update params={}{add=[/en/45_2006 (1628172286382047232), /en/9_2005 (1628172286626365440), /en/69_2004 (1628172286630559744), /en/300_2007 (1628172286632656896), /en/2046_2004 (1628172286636851200)]} 0 1044
2019-03-16 14:21:32.487 ERROR (qtp802600647-22) [   x:films] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: ERROR: [doc=/en/quien_es_el_senor_lopez] Error adding field 'name'='¿Quién es el señor López?' msg=For input string: "¿Quién es el señor López?"
...
Caused by: java.lang.NumberFormatException: For input string: "¿Quién es el señor López?"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:538)
    at org.apache.solr.schema.DoublePointField.createField(DoublePointField.java:156)
    at org.apache.solr.schema.PointField.createFields(PointField.java:250)
    at org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:65)
    at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:171)

Upvotes: 4

Views: 491

Answers (2)

MatsLindh
MatsLindh

Reputation: 52802

The error message tells you that Solr has added a field type for the field you're submitting as a double field. This happens when the first document you submit has a numeric value in the field, and you haven't added explicit field types - since this will require Solr to guess the field types (i.e. the schemaless mode is active).

Caused by: **java.lang.NumberFormatException**: For input string: "¿Quién es el señor López?"
    at sun.misc.**FloatingDecimal**.readJavaFormatString(FloatingDecimal.java:2043)

The schemaless mode is useful for quick prototyping and experimenting, but when importing actual, live data you should always define your fields first so you avoid cases like this.

This is also why defining the fields first works as expected, since Solr then don't have to guess what the field type is based on the first document with the field present.

Upvotes: 2

Hector Correa
Hector Correa

Reputation: 26690

I get the same error if I try to import the file on a brand new Solr core:

$ solr create -c films
$ post -c films example/films/films.xml 

However, the post works correcly if I add a field to the core before importing the data, which is described in the README.txt of the films example:

$ solr delete -c films
$ solr create -c films
$ curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:application/json' --data-binary '{
    "add-field" : {
        "name":"name",
        "type":"text_general",
        "multiValued":false,
        "stored":true
    },
    "add-field" : {
        "name":"initial_release_date",
        "type":"pdate",
        "stored":true
    }
}'

$ post -c films example/films/films.xml 

Upvotes: 3

Related Questions