No negative startindices supported anymore
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
index f7fcac1..41fdd1f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
@@ -67,8 +67,20 @@
             ).toQuery();
 
 
-	KorapResult kr = kc.search(query);
+	// KorapResult kr = kc.search(query);
 
-	System.err.println(kr.toJSON());
+	//	System.err.println(kr.toJSON());
+
+
+	//	kc = new KorapCollection("{\"meta\":[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"A00\"}},{\"@type\":\"korap:meta-extend\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"A01\"}}]}");
+
+	//	kc = new KorapCollection("{\"meta\":[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"A01\"}}]}");
+	kc = new KorapCollection("{\"meta\":[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#textClass\",\"@value\":\"reisen\"}}]}");
+	kc.setIndex(ki);
+
+	System.err.println(kc.getFilter(0).toString());
+	System.err.println(kc.numberOf("documents"));
+
+	// assertEquals(14, kc.numberOf("documents"));
     };
-};
\ No newline at end of file
+};
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
index 3314648..935c94e 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -142,6 +142,48 @@
 
 
 
+    @Test
+    public void searchJSONindexboundary () throws IOException {
+
+	// Construct index
+	KorapIndex ki = new KorapIndex();
+	// Indexing test files
+	for (String i : new String[] {"00001", "00002", "00003", "00004", "00005", "00006", "02439"}) {
+	    ki.addDocFile(
+	      getClass().getResource("/wiki/" + i + ".json.gz").getFile(), true
+            );
+	};
+	ki.commit();
+
+	String json = getString(getClass().getResource("/queries/bsp-fail1.json").getFile());
+
+	KorapResult kr = new KorapSearch(json).run(ki);
+	assertEquals(0, kr.getStartIndex());
+	assertEquals(0, kr.getTotalResults());
+	assertEquals(25, kr.getItemsPerPage());
+    };
+
+    @Test
+    public void searchJSONindexboundary2 () throws IOException {
+
+	// Construct index
+	KorapIndex ki = new KorapIndex();
+	// Indexing test files
+	for (String i : new String[] {"00001", "00002", "00003", "00004", "00005", "00006", "02439"}) {
+	    ki.addDocFile(
+	      getClass().getResource("/wiki/" + i + ".json.gz").getFile(), true
+            );
+	};
+	ki.commit();
+
+	String json = getString(getClass().getResource("/queries/bsp-fail2.json").getFile());
+
+	KorapResult kr = new KorapSearch(json).run(ki);
+	assertEquals(50, kr.getItemsPerPage());
+	assertEquals(49950, kr.getStartIndex());
+	assertEquals(0, kr.getTotalResults());
+    };
+
 
     public static String getString (String path) {
 	StringBuilder contentBuilder = new StringBuilder();
diff --git a/src/test/resources/queries/bsp-fail1.json b/src/test/resources/queries/bsp-fail1.json
new file mode 100644
index 0000000..16c16a0
--- /dev/null
+++ b/src/test/resources/queries/bsp-fail1.json
@@ -0,0 +1,41 @@
+{
+    "@context": {
+        "@language": "de", 
+        "class": {
+            "@id": "korap:class", 
+            "@type": "xsd:integer"
+        }, 
+        "filter": "korap:filter", 
+        "korap": "http://korap.ids-mannheim.de/ns/query", 
+        "meta": "korap:meta", 
+        "operands": {
+            "@container": "@list", 
+            "@id": "korap:operands"
+        }, 
+        "query": "korap:query", 
+        "relation": {
+            "@id": "korap:relation", 
+            "@type": "korap:relation#types"
+        }
+    }, 
+    "query": {
+        "@type": "korap:group", 
+        "operands": [
+            {
+                "@type": "korap:element", 
+                "@value": "np"
+            }, 
+            {
+                "@type": "korap:token", 
+                "@value": {
+                    "@type": "korap:term", 
+                    "@value": "base:Mann", 
+                    "relation": "="
+                }
+            }
+        ], 
+        "position": "within", 
+        "relation": "position"
+    },
+    "startIndex": -2
+}
diff --git a/src/test/resources/queries/bsp-fail2.json b/src/test/resources/queries/bsp-fail2.json
new file mode 100644
index 0000000..8c8c58c
--- /dev/null
+++ b/src/test/resources/queries/bsp-fail2.json
@@ -0,0 +1,42 @@
+{
+    "@context": {
+        "@language": "de", 
+        "class": {
+            "@id": "korap:class", 
+            "@type": "xsd:integer"
+        }, 
+        "filter": "korap:filter", 
+        "korap": "http://korap.ids-mannheim.de/ns/query", 
+        "meta": "korap:meta", 
+        "operands": {
+            "@container": "@list", 
+            "@id": "korap:operands"
+        }, 
+        "query": "korap:query", 
+        "relation": {
+            "@id": "korap:relation", 
+            "@type": "korap:relation#types"
+        }
+    }, 
+    "query": {
+        "@type": "korap:group", 
+        "operands": [
+            {
+                "@type": "korap:element", 
+                "@value": "np"
+            }, 
+            {
+                "@type": "korap:token", 
+                "@value": {
+                    "@type": "korap:term", 
+                    "@value": "base:Mann", 
+                    "relation": "="
+                }
+            }
+        ], 
+        "position": "within", 
+        "relation": "position"
+    },
+    "count": 100,
+    "startPage": 1000
+}