Collection queries and missing negation queries
diff --git a/src/main/java/de/ids_mannheim/korap/KorapCollection.java b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
index 4e6b57b..ff0ef24 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
@@ -83,10 +83,15 @@
 	this.filter = new ArrayList<FilterOperation>(5);
     };
 
+
     public void fromJSON (JsonNode json) throws QueryException {
 	this.filter(new KorapFilter(json));
     };
 
+
+    /**
+     * Legacy API for collection filters.
+     */
     public void fromJSONLegacy (JsonNode json) throws QueryException {
 	String type = json.get("@type").asText();
 
diff --git a/src/main/java/de/ids_mannheim/korap/KorapFilter.java b/src/main/java/de/ids_mannheim/korap/KorapFilter.java
index a391d83..55ad51f 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapFilter.java
@@ -114,6 +114,8 @@
 		if (json.has("match"))
 		    match = json.get("match").asText();
 
+
+		// TODO: This isn't stable yet
 		switch (match) {
 		case "match:eq":
 		    filter.date(date);
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionJSON.java b/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionJSON.java
index 0399e55..910f574 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionJSON.java
@@ -22,6 +22,7 @@
     public void collection1 () {
 	String metaQuery = _getJSONString("collection_1.jsonld");
 	KorapCollection kc = new KorapCollection(metaQuery);
+	System.err.println(kc.toString());
     };
 
     private String _getJSONString (String file) {
diff --git a/src/test/resources/queries/collections/collection_4.jsonld b/src/test/resources/queries/collections/collection_4.jsonld
new file mode 100644
index 0000000..ceda325
--- /dev/null
+++ b/src/test/resources/queries/collections/collection_4.jsonld
@@ -0,0 +1,12 @@
+{
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+  "errors" : [ ],
+  "warnings" : [ ],
+  "announcements" : [ ],
+  "collection" : {
+    "@type": "korap:doc",
+    "key" : "title",
+    "value" : "Mannheim",
+    "match" : "match:contains"
+  }
+}
diff --git a/src/test/resources/queries/collections/readme.txt b/src/test/resources/queries/collections/readme.txt
index 5c64025..384e4e0 100644
--- a/src/test/resources/queries/collections/readme.txt
+++ b/src/test/resources/queries/collections/readme.txt
@@ -1,3 +1,4 @@
 Collection 1: "pubDate = 2000-01-01",
 Collection 2: "1990 < pubDate <= 2006",
 Collection 3: "author < Schmitt". 
+Collection 4: "title~Mannheim"
diff --git a/src/test/resources/queries/sequence/negative-last-constraint.jsonld b/src/test/resources/queries/sequence/negative-last-constraint.jsonld
new file mode 100644
index 0000000..6c61d11
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-last-constraint.jsonld
@@ -0,0 +1,41 @@
+{
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query" : {
+    "@type" : "korap:group",
+    "operation" : "operation:sequence",
+    "distances" : [
+      {
+      "@type" : "korap:distance",
+      "boundary" : {
+	"@type" : "korap:boundary",
+	"min" : 1,
+	"max" : 2
+      },
+      "key" : "w",
+      "inOrder" : false
+      }
+    ],
+    "operands" : [
+      {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "foundry" : "tt",
+          "key" : "NN",
+          "layer" : "p",
+          "match" : "match:eq"
+        }
+      },
+      {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "foundry" : "tt",
+          "key" : "NN",
+          "layer" : "p",
+          "match" : "match:ne"
+        }
+      }
+    ]
+  }
+}
diff --git a/src/test/resources/queries/sequence/negative-last-sequence-2.jsonld b/src/test/resources/queries/sequence/negative-last-sequence-2.jsonld
new file mode 100644
index 0000000..3e6f4dd
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-last-sequence-2.jsonld
@@ -0,0 +1,45 @@
+{
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query" : {
+    "@type" : "korap:group",
+    "operation" : "operation:sequence",
+    "operands" : [
+      {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "foundry" : "tt",
+          "key" : "NN",
+          "layer" : "p",
+          "match" : "match:ne"
+        }
+      },
+      {
+	"@type" : "korap:group",
+	"operation" : "operation:sequence",
+	"operands" : [
+	  {
+	    "@type" : "korap:token",
+	    "wrap" : {
+	      "@type" : "korap:term",
+	      "foundry" : "tt",
+	      "key" : "DET",
+	      "layer" : "p",
+	      "match" : "match:ne"
+	    }
+	  },
+	  {
+	    "@type" : "korap:token",
+	    "wrap" : {
+	      "@type" : "korap:term",
+	      "foundry" : "tt",
+	      "key" : "ADJ",
+	      "layer" : "p",
+	      "match" : "match:eq"
+	    }
+	  }
+	]
+      }
+    ]
+  }
+}
diff --git a/src/test/resources/queries/sequence/negative-last-sequence.jsonld b/src/test/resources/queries/sequence/negative-last-sequence.jsonld
new file mode 100644
index 0000000..c3e2777
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-last-sequence.jsonld
@@ -0,0 +1,45 @@
+{
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query" : {
+    "@type" : "korap:group",
+    "operation" : "operation:sequence",
+    "operands" : [
+      {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "foundry" : "tt",
+          "key" : "NN",
+          "layer" : "p",
+          "match" : "match:eq"
+        }
+      },
+      {
+	"@type" : "korap:group",
+	"operation" : "operation:sequence",
+	"operands" : [
+	  {
+	    "@type" : "korap:token",
+	    "wrap" : {
+	      "@type" : "korap:term",
+	      "foundry" : "tt",
+	      "key" : "DET",
+	      "layer" : "p",
+	      "match" : "match:ne"
+	    }
+	  },
+	  {
+	    "@type" : "korap:token",
+	    "wrap" : {
+	      "@type" : "korap:term",
+	      "foundry" : "tt",
+	      "key" : "ADJ",
+	      "layer" : "p",
+	      "match" : "match:ne"
+	    }
+	  }
+	]
+      }
+    ]
+  }
+}