Added query-param show-snippet to the search web-service (solves #322)
Change-Id: Id0719fc2dd1166ae083418e27e6b15c0aaa4a289
diff --git a/core/Changes b/core/Changes
index 71d464d..1189922 100644
--- a/core/Changes
+++ b/core/Changes
@@ -3,6 +3,7 @@
- Added data folder containing super_client_info and database
for mounting into docker
- Removed the API authentication scheme from www-authenticate header
+- Added query-param show-snippet to the search web-service (solves #322)
# version 0.69.4
diff --git a/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java b/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
index f1b70ef..526d1e5 100644
--- a/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
+++ b/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
@@ -136,7 +136,7 @@
String q, String ql, String v, List<String> cqList, String fields,
String pipes, Integer pageIndex, Integer pageInteger, String ctx,
Integer pageLength, Boolean cutoff, boolean accessRewriteDisabled,
- boolean showTokens)
+ boolean showTokens, boolean showSnippet)
throws KustvaktException {
if (pageInteger != null && pageInteger < 1) {
@@ -169,7 +169,7 @@
MetaQueryBuilder meta = createMetaQuery(pageIndex, pageInteger, ctx,
pageLength, cutoff, corpusAccess, fieldList, accessRewriteDisabled,
- showTokens);
+ showTokens, showSnippet);
serializer.setMeta(meta.raw());
// There is an error in query processing
@@ -322,7 +322,7 @@
Integer pageInteger, String ctx, Integer pageLength,
Boolean cutoff, CorpusAccess corpusAccess, List<String> fieldList,
boolean accessRewriteDisabled,
- boolean showTokens) {
+ boolean showTokens, boolean showSnippet) {
MetaQueryBuilder meta = new MetaQueryBuilder();
meta.addEntry("startIndex", pageIndex);
meta.addEntry("startPage", pageInteger);
@@ -330,7 +330,7 @@
meta.addEntry("count", pageLength);
// todo: what happened to cutoff?
meta.addEntry("cutOff", cutoff);
- meta.addEntry("snippets", !accessRewriteDisabled);
+ meta.addEntry("snippets", (showSnippet && !accessRewriteDisabled));
if (!accessRewriteDisabled) {
meta.addEntry("tokens", showTokens);
}
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
index 7c180e8..4dd51c7 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
@@ -227,6 +227,7 @@
@QueryParam("pipes") String pipes,
@QueryParam("access-rewrite-disabled") boolean accessRewriteDisabled,
@QueryParam("show-tokens") boolean showTokens,
+ @DefaultValue("true") @QueryParam("show-snippet") boolean showSnippet,
@QueryParam("cq") List<String> cq,
@QueryParam("engine") String engine) {
@@ -239,7 +240,7 @@
result = searchService.search(engine, context.getUsername(),
headers, q, ql, v, cq, fields, pipes, pageIndex,
pageInteger, ctx, pageLength, cutoff,
- accessRewriteDisabled, showTokens);
+ accessRewriteDisabled, showTokens, showSnippet);
}
catch (KustvaktException e) {
throw kustvaktResponseHandler.throwit(e);