New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow PropertyPlaceholders in @SolrDocument solrCoreName [DATASOLR-304] #422
Comments
Ananth Ramchandran commented Is there an update on this ticket ?? I have a similar requirement in my app where the core name needs to be dynamically changed based on the environment at run time. I would appreciate any help in this.Thanks. (spring boot version used 1.3.3.RELEASE) |
Sunilkumar Peljur commented Any update on this issue? I am also in need of this feature |
Fei Tian commented I have exactly same requirement for this feature |
Shujathullah Mirza commented Is there any update on this ticket ?? |
Paul Wellner Bou commented Mirzaunstoppable, Sunilkumar Peljur, there is a workaround, but you will have to write a bit more code and you can't rely on the "magic" which is augenerating your query methods. See https://paul.wellnerbou.de/2018/08/21/using-spring-data-solr-with-configurable-solr-core/ Christoph Strobl, are there any plans to include a feature like this in future? If yes, I would try to create a pull request for you |
David Webb commented Thats a nice solution Paul Wellner Bou. Christoph Strobl and/or ogierke, I would be happy to write this PR if you could point me to the an example of how this is done in other SD projects and the part of SDSolr that should apply the PropertyPlaceholder to the |
Paul Wellner Bou commented This ticket is solved now, as I can read in the docs, correct? I was pointed to this feature documented in the documentation in one of the comments of the blog entry I linked above: https://paul.wellnerbou.de/2018/08/21/using-spring-data-solr-with-configurable-solr-core/#comment-4411778925
|
kaszuster commented Following the example in the [docs|https://docs.spring.io/spring-data/solr/docs/4.0.11.RELEASE/reference/html/#solr.misc.collection-name] gives me org.springframework.expression.spel.SpelEvaluationException: EL1057E: No bean resolver registered in the context to resolve access to bean 'collectionName' as soon as i create a repository that extends SolrCrudRepository However when i create a custom repository, i have to implement all crud operations by hand, to do that i have to use the SolrTemplate and there i have to provide a collection name anyway |
Christoph Strobl commented kaszuster can you please open a new issue related to DATASOLR-463 that describes the error in a bit more detail. If you have a failing test at hand that would be great |
kaszuster commented I did some more research and will try to open an issue later this day |
kaszuster commented yoyo tom yes, i have been able to solve my problem, howover i dont know if this is going to help you:
Here is how my configuration looks like (I changed a downloaded example to reproduce the problem)
import org.springframework.data.solr.repository.config.AbstractSolrConfiguration;
@Configuration
@EnableSolrRepositories(solrTemplateRef = "mySolrTemplate", basePackages = "com.doj.app.repository")
@ComponentScan
public class SolrConfig extends AbstractSolrConfiguration {
@Value("${spring.data.solr.host}")
String solrURL;
@Bean
public SolrClient solrClient() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("followRedirects", false);
params.set("allowCompression", false);
params.set("httpBasicAuthUser", "USERNAME");
params.set("httpBasicAuthPassword", "PASSWORD");
CloseableHttpClient httpClient = HttpClientUtil.createClient(params);
return new Builder(solrURL).withHttpClient(httpClient).build();
}
@Bean
public String collectionName() {
return "my-coll";
}
@Bean
@ConditionalOnMissingBean(name = "solrTemplate")
public SolrTemplate solrTemplate(@Qualifier("mySolrTemplate") SolrTemplate solrTemplate) {
return solrTemplate;
}
// because i have more than one solr server connected, you can ignore this
@Bean("mySolrTemplate")
public SolrTemplate mySolrTemplate(SolrClient solrClient, SolrConverter solrConverter) {
return new SolrTemplate(new HttpSolrClientFactory(solrClient), solrConverter); // this does work
// return new SolrTemplate(new HttpSolrClientFactory(solrClient)); // this does not
}
@Override
public SolrClientFactory solrClientFactory() {
return new HttpSolrClientFactory(solrClient());
}
} I will try to create a new ticket and upload an example project as soon as i have finished my daily business
Hope this helps.
|
David Webb opened DATASOLR-304 and commented
There are situations where the name of a solrCore may change in different environments. Example is a Lower Level Env (LLE) solr cluster that has cores suffixed with _dev _qa _stage, etc.
As a developer, have the ability to use PropertyPlaceholders in
solrCoreName
attribute of the@SolrDocument
Annotation.My attempts to do this with the latest
Gosling SR4
andHopper SR1
yields the following error that leads me to believe this is not currently supported and warrants an improvement request.Affects: 2.0.1 (Hopper SR1), 1.5.4 (Gosling SR4)
Issue Links:
@SolrDocument
("is superseded by")
11 votes, 10 watchers
The text was updated successfully, but these errors were encountered: