You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Sebastian Riemer <s....@littera.eu> on 2016/06/30 11:55:57 UTC

How to best serialize/deserialize a SolrInputDocument?

Hi,

I am looking for a way to serialize a SolrInputDocument.

I want to store the serialized document in a MySQL table.

Later I want to deserialize that document and send it to the Solr server.

Currently I am looking at org.apache.solr.client.solrj.request.UpdateRequest and JavaBinUpdateRequestCodec. There are two methods, marshal and unmarshal which look like I could use for that purpose.

I'd simply create an UpdateRequest, add the document to it, call marshal, save the OutputStream somehow in the MySQL table. When retrieving I pass the value from the MySQL as InputStream to the unmarshal method, get my UpdateRequest object, iterate the contained SolrInputDocument and send it to the server.

Am I on the right track, or is there a better approach?

The background to this is, that we want backup the generated documents which are indexed with solr. So if a client restores a backup, that MySQL table with the serialized documents can be used to rebuild the index as quickly as possible.

Thanks,
Sebastian