Added tokendistancespan bug test case
Change-Id: I280c861980ab4f2b5f9ee5075cda05de62655ac1
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
index fd2e7c3..9ac488f 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
@@ -3,6 +3,7 @@
import static de.ids_mannheim.korap.TestSimple.getString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import java.io.IOException;
@@ -806,6 +807,29 @@
@Test
+ public void searchJSONtokenDistanceSpanBug () throws IOException {
+ // Construct index
+ KrillIndex ki = new KrillIndex();
+ ki.addDoc(1, getClass().getResourceAsStream("/goe/AGX-00002.json"),
+ false);
+ ki.addDoc(2, getClass().getResourceAsStream("/bzk/D59-00089.json.gz"),
+ true);
+ ki.commit();
+
+ // ({1:Sonne []* Erde} | {2: Erde []* Sonne})
+ String json = getString(getClass().getResource(
+ "/queries/bugs/tokendistancespan_bug.jsonld").getFile());
+
+ Krill ks = new Krill(json);
+ Result kr = ks.apply(ki);
+ System.err.println(kr.toJsonString());
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode res = mapper.readTree(kr.toJsonString());
+ assertTrue(res.at("/errors").isMissingNode());
+ };
+
+
+ @Test
public void searchJSONCollection () throws IOException {
// Construct index
KrillIndex ki = new KrillIndex();
diff --git a/src/test/resources/queries/bugs/tokendistancespan_bug.jsonld b/src/test/resources/queries/bugs/tokendistancespan_bug.jsonld
new file mode 100644
index 0000000..7e442f8
--- /dev/null
+++ b/src/test/resources/queries/bugs/tokendistancespan_bug.jsonld
@@ -0,0 +1,109 @@
+{
+ "@context":"http://korap.ids-mannheim.de/ns/koral/0.3/context.jsonld",
+ "errors":[],
+ "warnings":[],
+ "messages":[
+ [303,"Deprecated 2014-07-24: 'min' and 'max' to be supported until 3 months from deprecation date."],
+ [303,"Deprecated 2014-07-24: 'min' and 'max' to be supported until 3 months from deprecation date."]
+ ],
+ "collection":{},
+ "query":{
+ "@type":"koral:group",
+ "operation":"operation:disjunction",
+ "operands":[
+ {
+ "@type":"koral:group",
+ "operation":"operation:class",
+ "classOut":1,
+ "operands":[
+ {
+ "@type":"koral:group",
+ "operation":"operation:sequence",
+ "operands":[
+ {
+ "@type":"koral:token",
+ "wrap":{
+ "@type":"koral:term",
+ "layer":"orth",
+ "key":"Mensch",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"koral:token",
+ "wrap":{
+ "@type":"koral:term",
+ "layer":"orth",
+ "key":"Stelle",
+ "match":"match:eq"
+ }
+ }
+ ],
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"koral:distance",
+ "key":"w",
+ "boundary":{
+ "@type":"koral:boundary",
+ "min":0
+ },
+ "min":0
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "@type":"koral:group",
+ "operation":"operation:class",
+ "classOut":2,
+ "operands":[
+ {
+ "@type":"koral:group",
+ "operation":"operation:sequence",
+ "operands":[
+ {
+ "@type":"koral:token",
+ "wrap":{
+ "@type":"koral:term",
+ "layer":"orth",
+ "key":"Stelle",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"koral:token",
+ "wrap":{
+ "@type":"koral:term",
+ "layer":"orth",
+ "key":"Mensch",
+ "match":"match:eq"
+ }
+ }
+ ],
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"koral:distance",
+ "key":"w",
+ "boundary":{
+ "@type":"koral:boundary",
+ "min":0
+ },
+ "min":0
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "meta":{
+ "highlight":[1,2],
+ "startPage":1,
+ "count":25,
+ "cutOff":true,
+ "context":"base/s:p"
+ }
+}