So, I found a way to programmatically restore a collection from a backup. I though that I could create a backup of a collection, put it on the classpath, restore it during unit test set up and run the queries against newly created collection using restore. Theoretically, it sounded like it would work.
I have following code doing the restore. CollectionAdminRequest.Restore restore = CollectionAdminRequest.restoreCollection( newCollectionName, backupName ) .setLocation( pathToBackup ); CollectionAdminResponse resp = restore.process( cluster.getSolrClient() ); AbstractDistribZkTestBase.waitForRecoveriesToFinish( newCollectionName, cluster.getSolrClient().getZkStateReader(), true, true, 30); However, any query I run against this new collection returns zero documents. I have tried queries which should match many documents but they all return zero documents. It seems like the data is not really loaded during the restore operation. I stepped through the "doRestore()" method of class RestoreCore.java which is internally doing the restore, I see that it has no errors or exceptions and the restore operation status is successful, but in reality there is no data in new collection. I see that new collection is created but it seems to be without any data. Am I missing something here? Any idea what could be the cause of this? Thanks! Pratik On Thu, Jun 6, 2019 at 11:18 AM Pratik Patel <pra...@semandex.net> wrote: > Thanks for the reply Alexandre, only special thing about JSON/XML is that > in order to export the data in that form, I need to have "docValues" > enabled for all the fields which are to be retrieved. I need to retrieve > all the fields and I can not enable docValues on all fields. > If there was a way to export data in JSON format without having to change > schema and index then I would have no issues with JSON. > I can not use "select" handler as it does not include parent/child > relationships. > > The options I have are following I guess. I am not sure if they are real > possibilities though. > > 1. Find a way to load pre-created index files either through > SolrCloudClient or directly to ZK > 2. Find a way to export the data in JSON format without having to make all > fields docValues enabled. > 3. Use Merge Index tool with an empty index and a real index. I am don't > know if it is possible to do this through solrJ though. > > Please let me know if there is better way available, it would really help. > Just so you know, I am trying to do this for unit tests related to solr > queries. Ultimately I want to load some pre-created data into > MiniSolrCloudCluster. > > Thanks a lot, > Pratik > > > On Wed, Jun 5, 2019 at 6:56 PM Alexandre Rafalovitch <arafa...@gmail.com> > wrote: > >> Is there something special about parent/child blocks you cannot do through >> JSON? Or XML? >> >> Both Solr XML and Solr JSON support it. >> >> New style parent/child mapping is also supported in latest Solr but I >> think >> it is done differently. >> >> Regards, >> Alex >> >> On Wed, Jun 5, 2019, 6:29 PM Pratik Patel, <pra...@semandex.net> wrote: >> >> > Hello Everyone, >> > >> > I am trying to write some unit tests for solr queries which requires >> some >> > data in specific state. There is a way to load this data through json >> files >> > but the problem is that the required data needs to have parent-child >> blocks >> > to be present. >> > Because of this, I would prefer if there is a way to load pre-created >> index >> > files into the cluster. >> > I checked the solr test framework and related examples but couldn't find >> > any example of index files being loaded in cloud mode. >> > >> > Is there a way to load index files into solr running in cloud mode? >> > >> > Thanks! >> > Pratik >> > >> >