Added config for total result cached and fixed #774.
Change-Id: I9be13e78c42f60664073b2b693ca90590c99cdf6
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index cb1cde5..1647e41 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -114,6 +114,7 @@
// EM: metadata restriction
// another variable might be needed to define which metadata fields are restricted
private boolean isMetadataRestricted = false;
+ private boolean totalResultCacheEnabled;
// EM: Maybe needed when we support pipe registration
@Deprecated
@@ -220,6 +221,9 @@
// network endpoint
networkEndpointURL = properties.getProperty("network.endpoint.url", "");
+ // cache
+ totalResultCacheEnabled = Boolean.valueOf(properties.getProperty(
+ "cache.total.results.enabled","true"));
}
@Deprecated
diff --git a/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java b/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
index e616295..5972577 100644
--- a/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
+++ b/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
@@ -211,7 +211,7 @@
int hashedKoralQuery = createTotalResultCacheKey(query);
boolean hasCutOff = hasCutOff(query);
- if (!hasCutOff) {
+ if (config.isTotalResultCacheEnabled() && !hasCutOff) {
query = precheckTotalResultCache(hashedKoralQuery, query);
}
@@ -229,7 +229,10 @@
}
// jlog.debug("Query result: " + result);
- result = afterCheckTotalResultCache(hashedKoralQuery, result);
+ if (config.isTotalResultCacheEnabled()) {
+ result = afterCheckTotalResultCache(hashedKoralQuery, result);
+ }
+
if (!hasCutOff) {
result = removeCutOff(result);
}
@@ -248,7 +251,7 @@
throws KustvaktException {
ObjectNode queryNode = (ObjectNode) JsonUtils.readTree(query);
queryNode.remove("meta");
- return queryNode.hashCode();
+ return queryNode.toString().hashCode();
}
private String afterCheckTotalResultCache (int hashedKoralQuery,