Is it possible to append data to existing SOLR document based on a field value?

518 views Asked by At

Currently, I have two databases that share only one field. I need to append the data from one database into the document generated by the other, but the mapping is one to many, such that multiple documents will have the new data appended to it. Is this possible in SOLR? I've read about nested documents, however, in this case the "child" documents would be shared by many "parent" documents.

Thank you.

1

There are 1 answers

1
Persimmonium On BEST ANSWER

I see two main options:

  1. you can write some client code using SolrJ that reads all data needed for a given doc from all datasources (doing a SQL join, looking up separate db, whatever), and then write the doc to Solr. Of course, you can (should) do this in batches if you can.
  2. you can index the first DB into Solr (using DIH if it's doable so it's quick to develop). It is imporntant you store all fields (or use docvalues) so you can have all your data back later. Then you write some client code that:

    a) retrieves all data about a doc

    b)gets all data that must be added from the other DB

    c) build a new representation of the doc (with client docs if needed)

    d) you update the doc, overwriting it