-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
from PR #844
- Loading branch information
Showing
5 changed files
with
78 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2024 B3Partners B.V. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
package org.tailormap.api.solr; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.apache.solr.client.solrj.SolrClient; | ||
import org.apache.solr.client.solrj.impl.ConcurrentUpdateHttp2SolrClient; | ||
import org.apache.solr.client.solrj.impl.Http2SolrClient; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class SolrService { | ||
@Value("${tailormap-api.solr-url}") | ||
private String solrUrl; | ||
|
||
@Value("${tailormap-api.solr-core-name:tailormap}") | ||
private String solrCoreName; | ||
|
||
/** | ||
* Get a concurrent update Solr client for bulk operations. | ||
* | ||
* @return the Solr client | ||
*/ | ||
public SolrClient getSolrClientForIndexing() { | ||
return new ConcurrentUpdateHttp2SolrClient.Builder( | ||
this.solrUrl + this.solrCoreName, | ||
new Http2SolrClient.Builder() | ||
.withFollowRedirects(true) | ||
.withConnectionTimeout(10000, TimeUnit.MILLISECONDS) | ||
.withRequestTimeout(60000, TimeUnit.MILLISECONDS) | ||
.build()) | ||
.withQueueSize(SolrHelper.SOLR_BATCH_SIZE * 2) | ||
.withThreadCount(10) | ||
.build(); | ||
} | ||
|
||
/** | ||
* Get a Solr client for searching. | ||
* | ||
* @return the Solr client | ||
*/ | ||
public SolrClient getSolrClientForSearching() { | ||
return new Http2SolrClient.Builder(this.solrUrl + this.solrCoreName) | ||
.withConnectionTimeout(10, TimeUnit.SECONDS) | ||
.withFollowRedirects(true) | ||
.build(); | ||
} | ||
|
||
public void setSolrUrl(String solrUrl) { | ||
this.solrUrl = solrUrl; | ||
} | ||
} |