@@ -903,27 +903,10 @@ arangodb::Result processInputDirectory(
903903 std::sort (collections.begin (), collections.end (), ::sortCollectionsForCreation);
904904
905905 std::unique_ptr<arangodb::RestoreFeature::JobData> usersData;
906+ std::unique_ptr<arangodb::RestoreFeature::JobData> analyzersData;
906907 std::vector<std::unique_ptr<arangodb::RestoreFeature::JobData>> jobs;
907908 jobs.reserve (collections.size ());
908909
909- // Step 2: create views
910- // @note: done after collection population since views might depend on data
911- // in restored collections
912- if (options.importStructure && !views.empty ()) {
913- LOG_TOPIC (" f723c" , INFO, Logger::RESTORE) << " # Creating views..." ;
914-
915- for (auto const & viewDefinition : views) {
916- LOG_TOPIC (" c608d" , DEBUG, Logger::RESTORE)
917- << " # Creating view: " << viewDefinition.toJson ();
918-
919- auto res = ::restoreView (httpClient, options, viewDefinition.slice ());
920-
921- if (!res.ok ()) {
922- return res;
923- }
924- }
925- }
926-
927910 bool didModifyFoxxCollection = false ;
928911 // Step 3: create collections
929912 for (VPackBuilder const & b : collections) {
@@ -961,13 +944,43 @@ arangodb::Result processInputDirectory(
961944 // reason is that loading into the users collection may change the
962945 // credentials for the current arangorestore connection!
963946 usersData = std::move (jobData);
947+ } else if (name.isString () && name.stringRef () == StaticStrings::AnalyzersCollection) {
948+ // special treatment for _analyzers collection - this must be the very first
949+ stats.totalCollections ++;
950+ analyzersData = std::move (jobData);
964951 } else {
965952 stats.totalCollections ++;
966953 jobs.push_back (std::move (jobData));
967954 }
968955 }
969-
970- // Step 4: fire up data transfer
956+
957+ // Step 4: restore data from _analyzers collection
958+ if (analyzersData) {
959+ // restore analyzers
960+ if (!jobQueue.queueJob (std::move (analyzersData))) {
961+ return Result (TRI_ERROR_OUT_OF_MEMORY, " unable to queue restore job" );
962+ }
963+
964+ jobQueue.waitForIdle ();
965+ }
966+
967+ // Step 5: create arangosearch views
968+ if (options.importStructure && !views.empty ()) {
969+ LOG_TOPIC (" f723c" , INFO, Logger::RESTORE) << " # Creating views..." ;
970+
971+ for (auto const & viewDefinition : views) {
972+ LOG_TOPIC (" c608d" , DEBUG, Logger::RESTORE)
973+ << " # Creating view: " << viewDefinition.toJson ();
974+
975+ auto res = ::restoreView (httpClient, options, viewDefinition.slice ());
976+
977+ if (!res.ok ()) {
978+ return res;
979+ }
980+ }
981+ }
982+
983+ // Step 6: fire up data transfer
971984 for (auto & job : jobs) {
972985 if (!jobQueue.queueJob (std::move (job))) {
973986 return Result (TRI_ERROR_OUT_OF_MEMORY, " unable to queue restore job" );
@@ -1045,6 +1058,7 @@ arangodb::Result processInputDirectory(
10451058 return firstError;
10461059 }
10471060 }
1061+
10481062 } catch (std::exception const & ex) {
10491063 return {TRI_ERROR_INTERNAL,
10501064 std::string (
0 commit comments