Fixed rare highlighting bug
diff --git a/src/main/java/de/ids_mannheim/korap/KorapCollection.java b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
index 422a97a..446c085 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
@@ -81,7 +81,7 @@
     // Todo: Create new KorapSearch Object!
 
     public KorapResult search (SpanQuery query) {
-	return this.index.search(this, query, 17, (short) 20, true, (short) 5, true, (short) 5);
+	return this.index.search(this, query, 0, (short) 20, true, (short) 5, true, (short) 5);
     };
 
     public FixedBitSet bits (AtomicReaderContext atomic) throws IOException  {
diff --git a/src/main/java/de/ids_mannheim/korap/KorapMatch.java b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
index 8d56f83..f1b57cb 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapMatch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
@@ -546,24 +546,53 @@
 
         LinkedList<int[]> spans = new LinkedList<int[]>();
 
-	spans.add(new int[]{ startPosChar - startOffsetChar, endPosChar - startOffsetChar, -1, 0});
+	// Todo: Simplify
+	int[] intArray = new int[]{ startPosChar - startOffsetChar, endPosChar - startOffsetChar, -1, 0};
+	log.trace("IntArray: {}", intArray);
+	spans.add(intArray);
 
 	// highlights
+	// I'm not sure about this.
 	if (this.highlight != null) {
 	    for (int[] highlight : this.highlight) {
 
+		/*
+
+		int start = pto.start(ldid, highlight[0]);
+		int end = pto.end(ldid, highlight[1]);
+
+		// Todo: Does this have to be and or or?
+		if (start == -1 || end == -1)
+		    continue;
+
+		if (start > startOffsetChar) {
+		    start -= startOffsetChar;
+		}
+		else {
+		    start = 0;
+		};
+
+		end -= startOffsetChar;
+		*/
+
 		int start = pto.start(ldid, highlight[0]) - startOffsetChar;
 		int end = pto.end(ldid, highlight[1]) - startOffsetChar;
 
-		if (start == -1 & end == -1)
+		if (start < 0 || end < 0)
 		    continue;
 
-		spans.add(new int[]{
-			start,
-			end,
-			highlight[2],
-			0 // Dummy value for later
-		    });
+		intArray = new int[]{
+		    start,
+		    end,
+		    highlight[2],
+		    0 // Dummy value for later
+		};
+
+		log.trace("IntArray: {}", intArray);
+		log.trace("PTO-start: {}", pto.start(ldid, highlight[0]));
+		log.trace("PTO-end: {}", pto.end(ldid, highlight[1]));
+
+		spans.add(intArray);
 	    };
 	};
 
diff --git a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
index 62eb516..5e57185 100644
--- a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
+++ b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
@@ -116,6 +116,7 @@
 	Integer[] pair = this.offsets.get(ptoa);
 	if (pair == null)
 	    return -1;
+
 	return  pair[1];
     };
 
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index bf8fd29..a4c83b7 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,6 +1,6 @@
 ## logger file can be used with
 
-log4j.rootLogger = DEBUG, stdout
+# log4j.rootLogger = DEBUG, stdout
 
 #log4j.logger.de.ids_mannheim.korap.query.spans.ElementSpans = TRACE, stdout
 #log4j.logger.de.ids_mannheim.korap.query.spans.WithinSpans = TRACE, stdout
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
index 3a3e126..f2fe7aa 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -254,4 +254,39 @@
 	assertEquals("SnippetBrackets (6)", "... [c]", kr.match(6).snippetBrackets());
 	assertEquals("SnippetBrackets (6)", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span></span><span class=\"korap-match\">c</span>", kr.match(6).snippetHTML());
     };
+
+
+    @Test
+    public void indexExample3 () throws IOException {
+	KorapIndex ki = new KorapIndex();
+
+	// abcabcabac
+	FieldDocument fd = new FieldDocument();
+	fd.addTV("base",
+		 "abcabcabac",
+		 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]" +
+		 "[(1-2)s:b|i:b|_1#1-2]" +
+		 "[(2-3)s:c|i:c|_2#2-3]" +
+		 "[(3-4)s:a|i:a|_3#3-4]" +
+		 "[(4-5)s:b|i:b|_4#4-5]" +
+		 "[(5-6)s:c|i:c|_5#5-6]" +
+		 "[(6-7)s:a|i:a|_6#6-7]" +
+		 "[(7-8)s:b|i:b|_7#7-8]" +
+		 "[(8-9)s:a|i:a|_8#8-9]" +
+		 "[(9-10)s:c|i:c|_9#9-10]");
+	ki.addDoc(fd);
+
+	ki.commit();
+
+	KorapResult kr;
+
+	KorapQuery kq = new KorapQuery("base");
+
+	SpanQuery sq = kq._(1,kq.seq(kq.seg("s:b")).append(kq.seg("s:a")).append(kq._(2,kq.seg("s:c")))).toQuery();
+
+	kr = ki.search(sq, 0, (short) 20, true, (short) 2, true, (short) 5);
+
+	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("SnippetBrackets (0)", "... ca[{1:ba{2:c}}]", kr.match(0).snippetBrackets());
+    };
 };
diff --git a/src/test/resources/wiki/AUG-55286.json.gz b/src/test/resources/wiki/AUG-55286.json.gz
new file mode 100644
index 0000000..a93f558
--- /dev/null
+++ b/src/test/resources/wiki/AUG-55286.json.gz
Binary files differ