try:

  public static SolrInputDocument toSolrInputDocument( SolrDocument d )
  {
    SolrInputDocument doc = new SolrInputDocument();
    for( String name : d.getFieldNames() ) {
      doc.addField( name, d.getFieldValue(name), 1.0f );
    }
    return doc;
  }

perhaps we should add this to ClientUtils.java


Brian Whitman wrote:
Writing a utility in java to do a copy from one solr index to another.
I query for the documents I want to copy:

SolrQuery q = new SolrQuery();
q.setQuery("dogs");
QueryResponse rq = source_solrserver.query(q);
for( SolrDocument d : rq.getResults() ) {
    // now I want to add these to a new server after modifying it slightly
    d.addField("newField", "somedata");
    dest_solrserver.add(d);
}

but that doesn't work-- add wants a SolrInputDocument, not a SolrDocument. I can't cast or otherwise easily create the former from the latter. How could I do this sort of thing?






Reply via email to