More testings for cutoff and returning -1 in case of a cutoff
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 f70ef99..9ce6090 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -213,6 +213,36 @@
assertEquals(5, kr.getItemsPerPage());
};
+ @Test
+ public void searchJSONstartPage () 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-paging.json").getFile());
+
+ KorapSearch ks = new KorapSearch(json);
+ KorapResult kr = ks.run(ki);
+ assertEquals(10, kr.getTotalResults());
+ assertEquals(5, kr.getStartIndex());
+ assertEquals(5, kr.getItemsPerPage());
+
+ json = getString(getClass().getResource("/queries/bsp-cutoff.json").getFile());
+ ks = ks = new KorapSearch(json);
+
+ kr = ks.run(ki);
+ assertEquals(-1, kr.getTotalResults());
+ assertEquals(2, kr.getStartIndex());
+ assertEquals(2, kr.getItemsPerPage());
+
+ };
public static String getString (String path) {
diff --git a/src/test/resources/queries/bsp-cutoff.json b/src/test/resources/queries/bsp-cutoff.json
new file mode 100644
index 0000000..0f1f834
--- /dev/null
+++ b/src/test/resources/queries/bsp-cutoff.json
@@ -0,0 +1,36 @@
+{
+ "@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:token",
+ "@value": {
+ "@type": "korap:term",
+ "@value": "base:alphabet",
+ "relation": "="
+ }
+ },
+ "startPage":2,
+ "count": 2,
+ "cutOff": true,
+ "context":{
+ "left":["char",90],
+ "right":["char",90]
+ }
+}
diff --git a/src/test/resources/queries/bsp-paging.json b/src/test/resources/queries/bsp-paging.json
new file mode 100644
index 0000000..ac352a7
--- /dev/null
+++ b/src/test/resources/queries/bsp-paging.json
@@ -0,0 +1,35 @@
+{
+ "@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:token",
+ "@value": {
+ "@type": "korap:term",
+ "@value": "base:alphabet",
+ "relation": "="
+ }
+ },
+ "startPage":2,
+ "count": 5,
+ "context":{
+ "left":["char",90],
+ "right":["char",90]
+ }
+}