0
votes

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 :)

2
Can you please shoe the definition of your string_filename fieldType.Paige Cook
the string_filename fieldtype is one I concocted with the lucene ICU libraries to include utf8 strings.Henry O.

2 Answers

0
votes

Looks like you are trying to index 2 values for id, namely 1 and 34d47c153efcf221.

0
votes

After much reading and experimenting. I found out what the issue was. In order to have dedupe enabled, I needed to add another field in the schema file. so something like

<field name="signature" type="string" stored="true" indexed="true" multiValued="false" / >

Then in my solrconfig, I need to set this field "signature" in the "signatureField" element:

 <updateRequestProcessorChain name="dedupe">
   <processor class="solr.processor.SignatureUpdateProcessorFactory">
     <bool name="enabled">true</bool>
     <str name="signatureField">signature</str>
     <bool name="overwriteDupes">false</bool>
     <str name="fields">id,name</str>
     <str name="signatureClass">solr.processor.Lookup3Signature</str>
   </processor>
   <processor class="solr.LogUpdateProcessorFactory" />
   <processor class="solr.RunUpdateProcessorFactory" />

Thanks to everyone who contributed! :)