No negative startindices supported anymore
diff --git a/src/main/java/de/ids_mannheim/korap/KorapCollection.java b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
index cdbb568..b2b47b8 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
@@ -93,20 +93,28 @@
// The checks asre not necessary
public KorapCollection filter (BooleanFilter filter) {
- if (filter == null)
+ log.trace("Added filter: {}", filter.toString());
+ if (filter == null) {
+ log.warn("No filter is given");
return this;
+ };
Filter f = (Filter) new QueryWrapperFilter(filter.toQuery());
- if (filter == null)
+ if (f == null) {
+ log.warn("Filter can't be wrapped");
return this;
+ };
FilterOperation fo = new FilterOperation(f,false);
- if (fo == null)
+ if (fo == null) {
+ log.warn("Filter operation invalid");
return this;
+ };
this.filter.add(fo);
this.filterCount++;
return this;
};
public KorapCollection extend (BooleanFilter filter) {
+ log.trace("Added extension: {}", filter.toString());
this.filter.add(
new FilterOperation(
(Filter) new QueryWrapperFilter(filter.toQuery()),
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndex.java b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
index 06d3edf..2c5ae31 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
@@ -327,7 +327,6 @@
public long numberOf (KorapCollection collection, String foundry, String type) throws IOException {
// Short cut for documents
if (type.equals("documents")) {
-
if (collection.getCount() <= 0) {
return (long) this.reader().numDocs();
};
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index 09b12a9..092c5a7 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -174,7 +174,7 @@
public KorapSearch setStartPage (int value) {
if (value >= 0) {
- this.startIndex = (value * this.getCount()) - this.getCount();
+ this.setStartIndex((value * this.getCount()) - this.getCount());
}
else {
this.startIndex = 0;
@@ -231,4 +231,4 @@
this.getCollection().setIndex(ki);
return ki.search(this.getCollection(), this);
};
-};
\ No newline at end of file
+};
diff --git a/src/main/resources/korap.conf b/src/main/resources/korap.conf
index a53826f..a418621 100644
--- a/src/main/resources/korap.conf
+++ b/src/main/resources/korap.conf
@@ -1,6 +1,6 @@
# Lucene Backend properties
lucene.properties = true
-lucene.index = /data/prep_corpus/index/
+lucene.index = /home/ndiewald/Repositories/korap/KorAP-modules/KorAP-lucene-index/sandbox/index
lucene.index.commit.count = 134217000
lucene.index.commit.log = log/korap.commit.log
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
+}