I'm trying to write some data from my java application to solr using solrj. I can query the solr server fine, but whenever I try to write some data to the server I get an error of invalid number, even when I'm writing a string to a string field.
Sample code to reproduce the error:
public class solrdocimport {
public static void main(String[] args) throws MalformedURLException, SolrServerException, IOException {
SolrClient client = new HttpSolrClient("http://192.168.175.136:8983/solr/nsf");
SolrInputDocument solrDoc = new SolrInputDocument();
solrDoc.addField("Subject", "Hello", 1.0f);
client.add(solrDoc);
}
}
The field "Subject" exists in the schema and it is defined as a String field, however the error I get is invalid number?
I've search around an cannot find anything in relation to this error. Does anyone know how to I can write to the solr server?
Sounds you might have some automatic ID generation in solrconfig.xml and then you changed your id field in schema.xml to be a number. Try changing id back to string, since you are not using it and see if the problem goes away.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.