Support expand query parameter for match retrieval

Change-Id: I9cf360441207ad86dcd76de1020368e409fe3d0d
diff --git a/core/Changes b/core/Changes
index 8700115..611af1f 100644
--- a/core/Changes
+++ b/core/Changes
@@ -5,6 +5,8 @@
    - Removed salt from config and updated config files.
 05/02/2020
    - Added welcome page.
+01/04/2020
+   - Support expand query parameter for match retrieval (diewald)
 11/05/2020
    - Added tool to create VC from list (diewald)
 29/05/2020
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 2d414f9..18a349c 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
@@ -360,13 +360,14 @@
     public String retrieveMatchInfo (String corpusId, String docId,
             String textId, String matchId, Set<String> foundries,
             String username, HttpHeaders headers, Set<String> layers,
-            boolean spans, boolean highlights) throws KustvaktException {
+            boolean spans, boolean sentenceExpansion,
+            boolean highlights) throws KustvaktException {
         String matchid =
                 searchKrill.getMatchId(corpusId, docId, textId, matchId);
 
         User user = createUser(username, headers);
         Pattern p = determineAvailabilityPattern(user);
-        
+
         boolean match_only = foundries == null || foundries.isEmpty();
         String results;
 //        try {
@@ -387,7 +388,7 @@
                 }
 
                 results = searchKrill.getMatch(matchid, foundryList, layerList,
-                        spans, highlights, true, p);
+                        spans, highlights, sentenceExpansion, p);
             }
             else {
                 results = searchKrill.getMatch(matchid, p);
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
index 8096c77..27665a2 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
@@ -33,10 +33,6 @@
 
     private static final boolean DEBUG = false;
 
-    // Temporary - shouldn't be here.
-    String indexDir = "/data/prep_corpus/index/";
-    String i = "/Users/hanl/Projects/prep_corpus";
-    String klinux10 = "/vol/work/hanl/indices";
     public static KrillIndex index;
 
     /**
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 128a0de..e3967b4 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
@@ -238,7 +238,7 @@
             @QueryParam("hls") Boolean highlights) throws KustvaktException {
 
         return retrieveMatchInfo(ctx, headers, locale, corpusId, docId, textId,
-                matchId, foundries, layers, spans, highlights);
+                                 matchId, foundries, layers, spans, "sentence", highlights);
     }
     
     @GET
@@ -253,9 +253,15 @@
             @QueryParam("foundry") Set<String> foundries,
             @QueryParam("layer") Set<String> layers,
             @QueryParam("spans") Boolean spans, 
+            @QueryParam("expand") String expansion, 
             // Highlights may also be a list of valid highlight classes
             @QueryParam("hls") Boolean highlights) throws KustvaktException {
 
+        Boolean expandToSentence = true;
+        if (expansion != null && (expansion.equals("false") || expansion.equals("null"))) {
+            expandToSentence = false;
+        }
+
         TokenContext tokenContext = (TokenContext) ctx.getUserPrincipal();
         scopeService.verifyScope(tokenContext, OAuth2Scope.MATCH_INFO);
         spans = spans != null ? spans : false;
@@ -265,7 +271,7 @@
         try{
             String results = searchService.retrieveMatchInfo(corpusId, docId,
                     textId, matchId, foundries, tokenContext.getUsername(),
-                    headers, layers, spans, highlights);
+                    headers, layers, spans, expandToSentence, highlights);
             return Response.ok(results).build();
         }
         catch (KustvaktException e) {