Clear payload for correct highlighting

Change-Id: Ia61dc5a4d035c92cb9d5262a4ca95c59af5cad01
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
index 5570b8f..52b657e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
@@ -15,6 +15,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+// Todo: Sort candidate spans only for negative start offsets!
+
 /**
  * Enumeration of SubSpans, which are parts of another Spans. The
  * SubSpans are specified with a start offset relative to the original
@@ -158,7 +160,8 @@
             cs.setEnd(firstSpans.end());
         }
 
-        // matchPayload.clear();
+        // Claer payloads of candidatespan
+        cs.getPayloads().clear();
 
         // Remove element payloads
         for (byte[] payload : firstSpans.getPayload()) {
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index 1945bdb..7e03f21 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -6,7 +6,7 @@
 # Spans:
 # log4j.logger.de.ids_mannheim.korap.query.spans.ElementSpans = TRACE, stdout
 # log4j.logger.de.ids_mannheim.korap.query.spans.AttributeSpans = TRACE, stdout
-log4j.logger.de.ids_mannheim.korap.query.spans.SubSpans = TRACE, stdout
+# log4j.logger.de.ids_mannheim.korap.query.spans.SubSpans = TRACE, stdout
 # log4j.logger.de.ids_mannheim.korap.query.spans.ElementAttributeSpans = TRACE, stdout
 # log4j.logger.de.ids_mannheim.korap.query.spans.KorapTermSpan = TRACE, stdout
 # log4j.logger.de.ids_mannheim.korap.query.spans.WithinSpans = TRACE, stdout
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
index eb719b1..d0af112 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
@@ -141,13 +141,21 @@
         ki.commit();
         SpanSubspanQuery ssq = new SpanSubspanQuery(new SpanElementQuery("base", "x"), -1, 1, true);
         kr = ki.search(ssq, (short) 10);
-        
+
+        /*        
         for (Match km : kr.getMatches()) {
             System.out.println(km.getStartPos() + "," + km.getEndPos()
                     + km.getSnippetBrackets());
         }
+        */
+
         assertEquals(2, kr.getTotalResults());
+        assertEquals(1, kr.getMatch(0).getStartPos());
+        assertEquals(2, kr.getMatch(0).getEndPos());
         assertEquals("a [b ]c ", kr.getMatch(0).getSnippetBrackets());
+
+        assertEquals(2, kr.getMatch(1).getStartPos());
+        assertEquals(3, kr.getMatch(1).getEndPos());
         assertEquals("a b [c ]", kr.getMatch(1).getSnippetBrackets());
     };
 };