I'm following the examples given on the wiki page to index a page via solrj. i've tried various ways to get this to work but somehow, i keep getting an error that looks like this:
ERROR: [doc=1] multiple values encountered for non multiValued field id: [1, 34d47c153efcf221]
My schema is pretty simple (just for test)
<field name="id" type="int" indexed="true" stored="true" required="true" /> <field name="name" type="string_filename" indexed="true" stored="true" required="true"/> <field name="size" type="int" indexed="true" stored="true" required="true"/> <field name="created_at" type="date" indexed="true" stored="true"/> <field name="updated_at" type="date" indexed="true" stored="true"/>
The code looks like this:
String solrHost = "localhost";
String coreName = "files";
SolrServer solr = null;
try {
solr = new CommonsHttpSolrServer("http://"+solrHost+":8983/solr/"+coreName);
} catch (Exception e) {
System.out.println("ERROR:" + e.getMessage());
}
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", 1);
doc.addField("name", "testfile.pdf");
doc.addField("size", 34234234);
try{
`solr.add(doc);
} catch (Exception e) {
System.out.println("ERROR adding docs: " + e.getMessage());
}
try{
solr.commit();
} catch (Exception e) {
System.out.println("commit FAiled.");
}
Hopefully it's something really trivial that i'm missing. Any help is appreciated :)
string_filename
fieldType. – Paige Cook