mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +00:00
Add this feature to SOLR Core properties, in order to allow the user to switch on the compression depending on his environment and use case.
This commit is contained in:
@@ -174,6 +174,14 @@ solr.suggester.enabled=true
|
|||||||
# -1 to disable suggester build throttling
|
# -1 to disable suggester build throttling
|
||||||
solr.suggester.minSecsBetweenBuilds=3600
|
solr.suggester.minSecsBetweenBuilds=3600
|
||||||
|
|
||||||
|
#
|
||||||
|
# Request content text compression
|
||||||
|
# When enabling this option, Tomcat Connector or HTTP Web Proxy (NGINX, Apache) compression must be also enabled
|
||||||
|
# This setting can improve performance when having high network latency or large documents in the repository
|
||||||
|
#
|
||||||
|
solr.request.content.compress=false
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Limit the maximum text size of transformed content sent to the index - in bytes
|
# Limit the maximum text size of transformed content sent to the index - in bytes
|
||||||
#
|
#
|
||||||
|
@@ -174,6 +174,13 @@ solr.suggester.enabled=true
|
|||||||
# -1 to disable suggester build throttling
|
# -1 to disable suggester build throttling
|
||||||
solr.suggester.minSecsBetweenBuilds=3600
|
solr.suggester.minSecsBetweenBuilds=3600
|
||||||
|
|
||||||
|
#
|
||||||
|
# Request content text compression
|
||||||
|
# When enabling this option, Tomcat Connector or HTTP Web Proxy (NGINX, Apache) compression must be also enabled
|
||||||
|
# This setting can improve performance when having high network latency or large documents in the repository
|
||||||
|
#
|
||||||
|
solr.request.content.compress=false
|
||||||
|
|
||||||
#
|
#
|
||||||
# Limit the maximum text size of transformed content sent to the index - in bytes
|
# Limit the maximum text size of transformed content sent to the index - in bytes
|
||||||
#
|
#
|
||||||
|
@@ -115,15 +115,32 @@ public class SOLRAPIClient
|
|||||||
private JsonFactory jsonFactory;
|
private JsonFactory jsonFactory;
|
||||||
private NamespaceDAO namespaceDAO;
|
private NamespaceDAO namespaceDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This option enables ("Accept-Encoding": "gzip") header for compression
|
||||||
|
* in GET_CONTENT requests. Additional configuration is required in
|
||||||
|
* Alfresco Repository Tomcat Connector or HTTP Web Proxy to deal w
|
||||||
|
* with compressed requests.
|
||||||
|
*/
|
||||||
|
private boolean compression;
|
||||||
|
|
||||||
public SOLRAPIClient(AlfrescoHttpClient repositoryHttpClient,
|
public SOLRAPIClient(AlfrescoHttpClient repositoryHttpClient,
|
||||||
DictionaryService dictionaryService,
|
DictionaryService dictionaryService,
|
||||||
NamespaceDAO namespaceDAO)
|
NamespaceDAO namespaceDAO)
|
||||||
|
{
|
||||||
|
this(repositoryHttpClient, dictionaryService, namespaceDAO, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SOLRAPIClient(AlfrescoHttpClient repositoryHttpClient,
|
||||||
|
DictionaryService dictionaryService,
|
||||||
|
NamespaceDAO namespaceDAO,
|
||||||
|
boolean compression)
|
||||||
{
|
{
|
||||||
this.repositoryHttpClient = repositoryHttpClient;
|
this.repositoryHttpClient = repositoryHttpClient;
|
||||||
this.dictionaryService = dictionaryService;
|
this.dictionaryService = dictionaryService;
|
||||||
this.namespaceDAO = namespaceDAO;
|
this.namespaceDAO = namespaceDAO;
|
||||||
this.deserializer = new SOLRDeserializer(namespaceDAO);
|
this.deserializer = new SOLRDeserializer(namespaceDAO);
|
||||||
this.jsonFactory = new JsonFactory();
|
this.jsonFactory = new JsonFactory();
|
||||||
|
this.compression = compression;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1125,7 +1142,10 @@ public class SOLRAPIClient
|
|||||||
{
|
{
|
||||||
headers.put("If-Modified-Since", String.valueOf(DateUtil.formatDate(new Date(modifiedSince))));
|
headers.put("If-Modified-Since", String.valueOf(DateUtil.formatDate(new Date(modifiedSince))));
|
||||||
}
|
}
|
||||||
headers.put("Accept-Encoding", "gzip");
|
if (compression)
|
||||||
|
{
|
||||||
|
headers.put("Accept-Encoding", "gzip");
|
||||||
|
}
|
||||||
req.setHeaders(headers);
|
req.setHeaders(headers);
|
||||||
|
|
||||||
Response response = repositoryHttpClient.sendRequest(req);
|
Response response = repositoryHttpClient.sendRequest(req);
|
||||||
|
@@ -143,6 +143,7 @@ public class SOLRAPIClientFactory
|
|||||||
alfrescoHost = props.getProperty("alfresco.host", "localhost");
|
alfrescoHost = props.getProperty("alfresco.host", "localhost");
|
||||||
alfrescoPort = Integer.parseInt(props.getProperty("alfresco.port", "8080"));
|
alfrescoPort = Integer.parseInt(props.getProperty("alfresco.port", "8080"));
|
||||||
alfrescoPortSSL = Integer.parseInt(props.getProperty("alfresco.port.ssl", "8443"));
|
alfrescoPortSSL = Integer.parseInt(props.getProperty("alfresco.port.ssl", "8443"));
|
||||||
|
boolean compression = Boolean.parseBoolean(props.getProperty("solr.request.content.compress", "false"));
|
||||||
|
|
||||||
SOLRAPIClient client = getCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
SOLRAPIClient client = getCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
||||||
if (client == null)
|
if (client == null)
|
||||||
@@ -171,7 +172,7 @@ public class SOLRAPIClientFactory
|
|||||||
maxHostConnections = Integer.parseInt(props.getProperty("alfresco.maxHostConnections", "40"));
|
maxHostConnections = Integer.parseInt(props.getProperty("alfresco.maxHostConnections", "40"));
|
||||||
socketTimeout = Integer.parseInt(props.getProperty("alfresco.socketTimeout", "60000"));
|
socketTimeout = Integer.parseInt(props.getProperty("alfresco.socketTimeout", "60000"));
|
||||||
|
|
||||||
client = new SOLRAPIClient(getRepoClient(keyResourceLoader), dictionaryService, namespaceDAO);
|
client = new SOLRAPIClient(getRepoClient(keyResourceLoader), dictionaryService, namespaceDAO, compression);
|
||||||
setCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL, client);
|
setCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user