I have a super simple question and need a counterpoint. I have a database with documents (they are definitely there).
I’m now using InitApplication and want to test whether my test data are there when starting up. I do it very bluntly:
ResultSet<DocumentReference> resultSet = documentQueryService.query("WorkflowStatus_DM", null, null, PageSpec.MAX_RESULTS, null);
So, I have no filter, no sorting, nothing. I just want to use a Select * to check if there is anything there and it says - no, there’s nothing in the DB, I’ll just create it all new and then my objects are there twice.
I’m in a greenfield project, using the project template, and have only added one migration step.
The first theory was that Solr isn’t ready? If so, what would I need to do?
Hello @soeren-round-ridge,
The documentQueryService will query the search index in Solr, according to GetA12 Login, your Select * needs to execute after the Index-Database synchronization process ends.
You can also refer the PersonMigration, we use the IDocumentRepository#findAllDocRefsForModel which does not rely on the index
Hope that will help.
Thanks for your quick reply!
But, shouldn’t that be done when the A12 migration process starts and again, if not, how do I wait for it?
Hello @soeren-round-ridge,
I have a quick test; you can listen on the DataServicesCustomInitializationEvent; that’s when the index is already present.
My setup is with embedded_solr, if this is your case also, please config
mgmtp.a12.dataservices.search.index.initialization.mode=update_index
Just to clarify, are you proposing that we create a listener to handle migrations instead of implementing a dedicated migration process?
Hello @soeren-round-ridge,
Sorry for the confusion. Focusing on the usage of documentQueryService:
- in the migration task, it will return empty. Alternatively, we have to use
IDocumentRepository#findAllDocRefsForModel
- in the DataServicesCustomInitializationEvent event, the indexing is fulfilled so that the documentQueryService will return the correct result.
So, I propose that if you insist on using documentQueryService for your task, it must be done via DataServicesCustomInitializationEvent. Otherwise, please consider IDocumentRepository.
Hi @soeren-round-ridge,
did the replies from @loi-risen-dale answer your question or do you need further support? If it is solved, please, use the checkbox to mark the solution to your problem so that other users also know what helped in your case.
Thanks in advance!
Denise from the Discourse team