Embedded Solr with persistent index?

I am trying to run a local DataServices instance with an embedded solr, but with a persisted index. My configuration is this:

mgmtp.a12.dataservices.search.solr.embedded.enabled=true
mgmtp.a12.dataservices.search.solr.embedded.location=c:/Projects/MyProject/A12/solr
mgmtp.a12.dataservices.search.solr.embedded.inMemory=false

However, it seems that embedded Solr always wants to recreate the index during startup. After I started DataServices once with mgmtp.a12.dataservices.search.index.initialization.mode=rebuild_index (because I have created documents outside of A12) and then start DataServices again (using mode=update_index or mode=regular) it fails with:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'embeddedSolrConfiguration.CoreUnloader' defined in URL [jar:file:/C:/Users/tkellerer/.gradle/caches/modules-2/files-2.1/com.mgmtp.a12.dataservices/dataservices-core-spring-boot-autoconfigure/37.1.0/d16d7d565e0d3a5ccba8cc4ba9afbbdc1793d34d/dataservices-core-spring-boot-autoconfigure-37.1.0.jar!/com/mgmtp/a12/dataservices/autoconfigure/search/internal/solr/EmbeddedSolrConfiguration$CoreUnloader.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'solrCoreContainer' defined in class path resource [com/mgmtp/a12/dataservices/autoconfigure/search/internal/solr/EmbeddedSolrConfiguration.class]: Unsatisfied dependency expressed through method 'solrCoreContainer' parameter 0: Error creating bean with name 'solrHome' defined in class path resource [com/mgmtp/a12/dataservices/autoconfigure/search/internal/solr/EmbeddedSolrConfiguration.class]: Failed to instantiate [java.nio.file.Path]: Factory method 'solrHome' threw exception with message: c:\Projects\MyProject\A12\solr\solr.xml
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:795)
  ....
  at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'solrCoreContainer' defined in class path resource [com/mgmtp/a12/dataservices/autoconfigure/search/internal/solr/EmbeddedSolrConfiguration.class]: Unsatisfied dependency expressed through method 'solrCoreContainer' parameter 0: Error creating bean with name 'solrHome' defined in class path resource [com/mgmtp/a12/dataservices/autoconfigure/search/internal/solr/EmbeddedSolrConfiguration.class]: Failed to instantiate [java.nio.file.Path]: Factory method 'solrHome' threw exception with message: c:\Projects\MyProject\A12\solr\solr.xml
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:795)
  ... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'solrHome' defined in class path resource [com/mgmtp/a12/dataservices/autoconfigure/search/internal/solr/EmbeddedSolrConfiguration.class]: Failed to instantiate [java.nio.file.Path]: Factory method 'solrHome' threw exception with message: c:\Projects\MyProject\A12\solr\solr.xml
  at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648)
  ... 38 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.nio.file.Path]: Factory method 'solrHome' threw exception with message: c:\Projects\MyProject\A12\solr\solr.xml
  at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:178)
  ... 52 common frames omitted
Caused by: java.nio.file.FileAlreadyExistsException: c:\Projects\MyProject\A12\solr\solr.xml
  ... 53 common frames omitted

Is there a way to tell the embedded Solr to (re)use the existing index, instead of trying to re-create it?

I am testing with about 500.000 documents, and having to go through a full index rebuild during startup each time is a bit tedious.

Hello @thomas-soft-grove,

That looks very similar to the bug A12-16513, please check it out if it’s your case.

Cheers,

Thanks. So I tried setting inMemory = false, which makes it start up again, but it will not persist the Solr index (which means it will re-index on every start).

I guess I’ll have to use an external Solr instance then.

Hello,
the issue from the ticket A12-16513 is fixed and will be part of 2024.06-ext4 release.