Added test for massive highlights
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index 0f0eb0e..7481d3e 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -1,6 +1,7 @@
package de.ids_mannheim.korap;
import java.io.*;
+import java.util.*;
import org.apache.lucene.search.spans.SpanQuery;
import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
@@ -37,6 +38,8 @@
private String error;
private String warning;
+ private HashSet<String> fields;
+
private JsonNode request;
public SearchContext context;
@@ -269,6 +272,12 @@
return this.itemsPerResource;
};
+ // Get map of fields to lift
+ public HashSet<String> getFields () {
+ if (this.fields != null)
+ return this.fields;
+ return (HashSet<String>) null;
+ };
public KorapSearch setCollection (KorapCollection kc) {
this.collection = kc;
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 6ee8366..59ac327 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -670,6 +670,46 @@
assertEquals(0, kr.getStartIndex());
};
+
+
+ @Test
+ public void searchJSONmultipleClassesBug () throws IOException {
+ // Construct index
+ KorapIndex ki = new KorapIndex();
+ // Indexing test files
+ ki.addDocFile(
+ 1,getClass().getResource("/bzk/D59-00089.json.gz").getFile(), true
+ );
+ ki.addDocFile(
+ 2,getClass().getResource("/bzk/D59-00089.json.gz").getFile(), true
+ );
+
+ ki.commit();
+
+ String json = getString(
+ getClass().getResource("/queries/bugs/multiple_classes.jsonld").getFile()
+ );
+
+ KorapSearch ks = new KorapSearch(json);
+ KorapResult kr = ks.run(ki);
+ assertEquals(
+ kr.getQuery(),
+ "{4: spanNext({1: spanNext({2: tokens:s:ins}, {3: tokens:s:Leben})}, tokens:s:gerufen)}"
+ );
+ assertEquals(
+ kr.getMatch(0).getSnippetBrackets(),
+ "... sozialistischen Initiative\" eine neue politische Gruppierung " +
+ "[{4:{1:{2:ins} {3:Leben}} gerufen}] hatten. " +
+ "Pressemeldungen zufolge haben sich in ..."
+ );
+
+ assertEquals(2, kr.getTotalResults());
+ assertEquals(0, kr.getStartIndex());
+ };
+
+
+
+
@Test
public void searchJSONCollection () throws IOException {
diff --git a/src/test/resources/queries/bugs/multiple_classes.jsonld b/src/test/resources/queries/bugs/multiple_classes.jsonld
new file mode 100644
index 0000000..3b5345c
--- /dev/null
+++ b/src/test/resources/queries/bugs/multiple_classes.jsonld
@@ -0,0 +1,74 @@
+{
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query": {
+ "@type" : "korap:group",
+ "class" : 4,
+ "classOut" : 4,
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "class" : 1,
+ "classOut" : 1,
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "class" : 2,
+ "classOut" : 2,
+ "operands" : [
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "key" : "ins",
+ "layer" : "orth",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:class"
+ },
+ {
+ "@type" : "korap:group",
+ "class" : 3,
+ "classOut" : 3,
+ "operands" : [
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "key" : "Leben",
+ "layer" : "orth",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:class"
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+ ],
+ "operation" : "operation:class"
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "key" : "gerufen",
+ "layer" : "orth",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+ ],
+ "operation" : "operation:class"
+ }
+}