Deserialization of new json-ld format
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
index 354797b..a6b7f70 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -20,7 +20,7 @@
 
     @Ignore
     public void queryJSONBsp1 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp1.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp1.jsonld").getFile());
 
 	// ([base=foo]|[base=bar])[base=foobar]
 	assertEquals(sqwi.toQuery().toString(), "");
@@ -29,7 +29,7 @@
     @Test
     public void queryJSONBsp1b () {
 
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp1b.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp1b.jsonld").getFile());
 
 	// [base=foo]|([base=foo][base=bar]) meta author=Goethe&year=1815
 	assertEquals(sqwi.toQuery().toString(), "spanOr([tokens:"+defaultFoundry+"l:foo, spanNext(tokens:"+defaultFoundry+"l:foo, tokens:"+defaultFoundry+"l:bar)])");
@@ -38,7 +38,7 @@
 
     @Test
     public void queryJSONBsp2 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp2.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp2.jsonld").getFile());
 
 	// ([base=foo]|[base=bar])[base=foobar]
 	assertEquals(sqwi.toQuery().toString(), "spanNext(spanOr([tokens:"+defaultFoundry+"l:foo, tokens:"+defaultFoundry+"l:bar]), tokens:"+defaultFoundry+"l:foobar)");
@@ -46,7 +46,7 @@
 
     @Test
     public void queryJSONBsp3 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp3.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp3.jsonld").getFile());
 
 	// shrink({[base=Mann]})
 	assertEquals(sqwi.toQuery().toString(), "shrink(0: {0: tokens:"+defaultFoundry+"l:Mann})");
@@ -54,7 +54,7 @@
 
     @Test
     public void queryJSONBsp4 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp4.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp4.jsonld").getFile());
 
 	// shrink({[base=foo]}[orth=bar])
 	assertEquals(sqwi.toQuery().toString(), "shrink(0: spanNext({0: tokens:"+defaultFoundry+"l:foo}, tokens:s:bar))");
@@ -62,7 +62,7 @@
 
     @Test
     public void queryJSONBsp5 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp5.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp5.jsonld").getFile());
 
 	// shrink(1:[base=Der]{1:[base=Mann]}) 
 	assertEquals(sqwi.toQuery().toString(), "shrink(1: spanNext(tokens:"+defaultFoundry+"l:Der, {1: tokens:"+defaultFoundry+"l:Mann}))");
@@ -70,7 +70,7 @@
 
     @Test
     public void queryJSONBsp6 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp6.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp6.jsonld").getFile());
 
 	// [base=katze]
 	assertEquals(sqwi.toQuery().toString(), "tokens:"+defaultFoundry+"l:Katze");
@@ -78,7 +78,7 @@
 
     @Ignore
     public void queryJSONBsp7 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp7.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp7.jsonld").getFile());
 
 	// [!base=Katze]
 	assertEquals(sqwi.toQuery().toString(), "");
@@ -94,7 +94,7 @@
 
     @Test
     public void queryJSONBsp9 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp9.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp9.jsonld").getFile());
 
 	// [base=Katze&orth=Katzen]
 	assertEquals(sqwi.toQuery().toString(), "spanSegment(tokens:"+defaultFoundry+"l:Katze, tokens:s:Katzen)");
@@ -102,7 +102,7 @@
 
     @Test
     public void queryJSONBsp10 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp10.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp10.jsonld").getFile());
 
 	// [base=Katze][orth=und][orth=Hunde]
 	assertEquals(sqwi.toQuery().toString(), "spanNext(spanNext(tokens:"+defaultFoundry+"l:Katze, tokens:s:und), tokens:s:Hunde)");
@@ -110,7 +110,7 @@
 
     @Ignore
     public void queryJSONBsp11 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp11.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp11.jsonld").getFile());
 
 	// [!(base=Katze&orth=Katzen)]
 	assertEquals(sqwi.toQuery().toString(), "");
@@ -118,7 +118,7 @@
 
     @Test
     public void queryJSONBsp12 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp12.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp12.jsonld").getFile());
 
 	// contains(<np>,[base=Mann])
 	assertEquals(sqwi.toQuery().toString(), "spanWithin(<tokens:np />, tokens:"+defaultFoundry+"l:Mann)");
@@ -126,7 +126,7 @@
 
     @Ignore
     public void queryJSONBsp13 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13.jsonld").getFile());
 
 	// startswith(<np>,[!pos=Det])
 	assertEquals(sqwi.toQuery().toString(), "");
@@ -134,15 +134,15 @@
 
     @Test
     public void queryJSONBsp13b () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13b.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13b.jsonld").getFile());
 
-	// startswith(<np>,[!pos=Det])
-	assertEquals(sqwi.toQuery().toString(), "spanWithin(<tokens:np />, tokens:pos:Det, 1)");
+	// startswith(<np>,[pos=Det])
+	assertEquals(sqwi.toQuery().toString(), "spanWithin(<tokens:np />, tokens:mate/p:Det, 1)");
     };
 
     @Test
     public void queryJSONBsp14 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp14.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp14.jsonld").getFile());
 
 	// 'vers{2,3}uch'
 	assertEquals(sqwi.toQuery().toString(), "SpanMultiTermQueryWrapper(tokens:/s:vers{2,3}uch/)");
@@ -150,7 +150,7 @@
 
     @Test
     public void queryJSONBsp15 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp15.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp15.jsonld").getFile());
 
 	// [orth='vers.*ch']
 	assertEquals(sqwi.toQuery().toString(), "SpanMultiTermQueryWrapper(tokens:/s:vers.*ch/)");
@@ -158,7 +158,7 @@
 
     @Test
     public void queryJSONBsp16 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp16.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp16.jsonld").getFile());
 
 	// [(base=bar|base=foo)&orth=foobar]
 	assertEquals(sqwi.toQuery().toString(), "spanSegment(spanOr([tokens:"+defaultFoundry+"l:bar, tokens:"+defaultFoundry+"l:foo]), tokens:s:foobar)");
@@ -166,7 +166,7 @@
 
     @Test
     public void queryJSONBsp17 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp17.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp17.jsonld").getFile());
 
 	// within(<np>,[base=Mann])
 	assertEquals(sqwi.toQuery().toString(), "spanWithin(<tokens:np />, tokens:"+defaultFoundry+"l:Mann)");
@@ -174,14 +174,14 @@
 
     @Test
     public void queryJSONDemo () throws QueryException {
-	SpanQueryWrapperInterface sqwi = new KorapQuery("tokens").fromJSON("{ \"query\" : { \"@type\" : \"korap:token\", \"@value\" : { \"@type\" : \"korap:term\", \"@value\" : \"base_p:foo\", \"relation\" : \"=\" }}}");
+	SpanQueryWrapperInterface sqwi = new KorapQuery("tokens").fromJSON("{ \"query\" : { \"@type\" : \"korap:token\", \"wrap\" : { \"@type\" : \"korap:term\", \"foundry\" : \"base\", \"layer\" : \"p\", \"key\" : \"foo\", \"match\" : \"match:eq\" }}}");
 
 	assertEquals(sqwi.toQuery().toString(), "tokens:base/p:foo");
     };
 
     @Test
     public void queryJSONBspClass () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp-class.json").getFile());
+	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp-class.jsonld").getFile());
 
 	// within(<np>,[base=Mann])
 	assertEquals(sqwi.toQuery().toString(), "{0: spanNext(tokens:tt/p:ADJA, tokens:mate/p:NN)}");
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 2b48eb0..9b5be8b 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -106,12 +106,11 @@
 	};
 	ki.commit();
 
-	String json = getString(getClass().getResource("/queries/metaquery3.json").getFile());
+	String json = getString(getClass().getResource("/queries/metaquery3.jsonld").getFile());
 
-	KorapResult kr = new KorapSearch(json).run(ki);
+	KorapSearch ks = new KorapSearch(json);
 	
-	//System.out.println(kr.getQuery().toString());	
-	
+	KorapResult kr = ks.run(ki);
 	assertEquals(66, kr.getTotalResults());
 	assertEquals(5, kr.getItemsPerPage());
 	assertEquals(5, kr.getStartIndex());
@@ -131,18 +130,19 @@
 	};
 	ki.commit();
 
-	String json = getString(getClass().getResource("/queries/metaquery4.json").getFile());
+	String json = getString(getClass().getResource("/queries/metaquery4.jsonld").getFile());
 
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
+
 	assertEquals(2, kr.getTotalResults());
 
-	json = getString(getClass().getResource("/queries/metaquery5.json").getFile());
+	json = getString(getClass().getResource("/queries/metaquery5.jsonld").getFile());
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 	assertEquals(2, kr.getTotalResults());
 
-	json = getString(getClass().getResource("/queries/metaquery6.json").getFile());
+	json = getString(getClass().getResource("/queries/metaquery6.jsonld").getFile());
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 	assertEquals(1, kr.getTotalResults());
@@ -183,7 +183,7 @@
 	};
 	ki.commit();
 
-	String json = getString(getClass().getResource("/queries/bsp-fail1.json").getFile());
+	String json = getString(getClass().getResource("/queries/bsp-fail1.jsonld").getFile());
 
 	KorapResult kr = new KorapSearch(json).run(ki);
 	assertEquals(0, kr.getStartIndex());
@@ -204,7 +204,7 @@
 	};
 	ki.commit();
 
-	String json = getString(getClass().getResource("/queries/bsp-fail2.json").getFile());
+	String json = getString(getClass().getResource("/queries/bsp-fail2.jsonld").getFile());
 
 	KorapResult kr = new KorapSearch(json).run(ki);
 	assertEquals(50, kr.getItemsPerPage());
@@ -226,7 +226,7 @@
 	};
 	ki.commit();
 
-	String json = getString(getClass().getResource("/queries/bsp-context.json").getFile());
+	String json = getString(getClass().getResource("/queries/bsp-context.jsonld").getFile());
 
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
@@ -241,7 +241,7 @@
 	assertEquals(5, kr.getItemsPerPage());
 
 
-	json = getString(getClass().getResource("/queries/bsp-context-2.json").getFile());
+	json = getString(getClass().getResource("/queries/bsp-context-2.jsonld").getFile());
 
 	kr = new KorapSearch(json).run(ki);
 	assertEquals(-1, kr.getTotalResults());
@@ -261,7 +261,7 @@
 	};
 	ki.commit();
 
-	String json = getString(getClass().getResource("/queries/bsp-paging.json").getFile());
+	String json = getString(getClass().getResource("/queries/bsp-paging.jsonld").getFile());
 
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
@@ -269,7 +269,7 @@
 	assertEquals(5, kr.getStartIndex());
 	assertEquals(5, kr.getItemsPerPage());
 
-	json = getString(getClass().getResource("/queries/bsp-cutoff.json").getFile());
+	json = getString(getClass().getResource("/queries/bsp-cutoff.jsonld").getFile());
 	ks = ks = new KorapSearch(json);
 
 	kr = ks.run(ki);
diff --git a/src/test/resources/queries/bsp-class.jsonld b/src/test/resources/queries/bsp-class.jsonld
new file mode 100644
index 0000000..f036535
--- /dev/null
+++ b/src/test/resources/queries/bsp-class.jsonld
@@ -0,0 +1,36 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query":{
+    "@type":"korap:group",
+    "operation" : "operation:class",
+   "class":0,
+    "operands":[
+      {
+	"@type":"korap:group",
+	"operation" : "operation:sequence",
+	"operands":[
+	  {
+	    "@type":"korap:token",
+	    "wrap":{
+	      "@type":"korap:term",
+	      "foundry":"tt",
+	      "layer" : "pos",
+	      "key" : "ADJA",
+	      "match":"match:eq"
+	    }
+	  },
+	  {
+	    "@type":"korap:token",
+	    "wrap":{
+	      "@type":"korap:term",
+	      "foundry":"mate",
+		"layer" : "p",
+	      "key" : "NN",
+	      "match":"match:eq"
+	    }
+	  }
+	]
+      }
+    ]
+  },
+  "meta":[{"@type":"korap:meta-filter","@value":{"@type":"korap:term","@field":"korap:field#corpusID","@value":"WPD"}}],"startPage":1,"count":50,"context":{"left":["token",6],"right":["token",6]}}
diff --git a/src/test/resources/queries/bsp-context-2.jsonld b/src/test/resources/queries/bsp-context-2.jsonld
new file mode 100644
index 0000000..576d2f6
--- /dev/null
+++ b/src/test/resources/queries/bsp-context-2.jsonld
@@ -0,0 +1,24 @@
+{"@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query":{
+   "@type":"korap:token",
+   "wrap":{
+     "@type":"korap:term",
+     "foundry" : "mate",
+     "layer":"l",
+     "key":"wert",
+     "match":"match:eq"
+   }
+ },
+ "meta":[
+   {
+     "@type":"korap:meta-filter",
+     "@value":{
+       "@type":"korap:term",
+       "@field":"korap:field#corpusID",
+       "@value":"WPD"
+     }
+   }
+ ],
+ "startPage":1,
+ "count":25,
+ "context":{"left":["char",210],"right":["char",210]},"cutOff":true}
diff --git a/src/test/resources/queries/bsp-context.jsonld b/src/test/resources/queries/bsp-context.jsonld
new file mode 100644
index 0000000..327b8be
--- /dev/null
+++ b/src/test/resources/queries/bsp-context.jsonld
@@ -0,0 +1,17 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:token", 
+    "wrap": {
+      "@type": "korap:term", 
+      "foundry": "mate",
+      "layer" : "l",
+      "key" : "alphabet", 
+      "match": "match:eq"
+    }
+  },
+  "context":{
+    "left":["char",90],
+    "right":["char",90]
+  }
+}
diff --git a/src/test/resources/queries/bsp-cutoff.jsonld b/src/test/resources/queries/bsp-cutoff.jsonld
new file mode 100644
index 0000000..fea64b8
--- /dev/null
+++ b/src/test/resources/queries/bsp-cutoff.jsonld
@@ -0,0 +1,20 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:token", 
+    "wrap": {
+      "@type": "korap:term", 
+      "foundry": "mate",
+      "layer": "lemma",
+      "key" : "alphabet", 
+      "match": "match:eq"
+    }
+  },
+  "startPage":2,
+  "count": 2,
+  "cutOff": true,
+  "context":{
+    "left":["char",90],
+    "right":["char",90]
+  }
+}
diff --git a/src/test/resources/queries/bsp-fail1.json b/src/test/resources/queries/bsp-fail1.json
index 16c16a0..a3e9bb3 100644
--- a/src/test/resources/queries/bsp-fail1.json
+++ b/src/test/resources/queries/bsp-fail1.json
@@ -1,25 +1,9 @@
 {
-    "@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"
-        }
-    }, 
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
     "query": {
         "@type": "korap:group", 
+        "frame": "frame:contains", 
+        "operation": "operation:position"
         "operands": [
             {
                 "@type": "korap:element", 
@@ -34,8 +18,6 @@
                 }
             }
         ], 
-        "position": "within", 
-        "relation": "position"
     },
     "startIndex": -2
 }
diff --git a/src/test/resources/queries/bsp-fail1.jsonld b/src/test/resources/queries/bsp-fail1.jsonld
new file mode 100644
index 0000000..d39a792
--- /dev/null
+++ b/src/test/resources/queries/bsp-fail1.jsonld
@@ -0,0 +1,25 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "query": {
+        "@type": "korap:group", 
+        "frame": "frame:contains", 
+        "operation": "operation:position"
+        "operands": [
+            {
+              "@type": "korap:span", 
+              "key": "np"
+            }, 
+            {
+                "@type": "korap:token", 
+                "wrap": {
+                  "@type": "korap:term", 
+		  "foundry" : "mate",
+                  "layer": "l",
+		  "key" : "Mann", 
+                  "match": "match:eq"
+                }
+            }
+        ], 
+    },
+    "startIndex": -2
+}
diff --git a/src/test/resources/queries/bsp-fail2.jsonld b/src/test/resources/queries/bsp-fail2.jsonld
new file mode 100644
index 0000000..417083e
--- /dev/null
+++ b/src/test/resources/queries/bsp-fail2.jsonld
@@ -0,0 +1,28 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:group", 
+    "operation": "operation:position",
+    "frame": "frame:contains", 
+    "operands": [
+      {
+        "@type": "korap:span", 
+	"foundry" : "cnx",
+	"layer" : "c",
+        "key": "np"
+      }, 
+      {
+        "@type": "korap:token", 
+        "wrap": {
+          "@type": "korap:term", 
+	  "foundry" : "mate",
+          "layer": "l",
+	  "key" : "Mann", 
+          "match": "match:eq"
+        }
+      }
+    ]
+  },
+  "count": 100,
+  "startPage": 1000
+}
diff --git a/src/test/resources/queries/bsp-paging.jsonld b/src/test/resources/queries/bsp-paging.jsonld
new file mode 100644
index 0000000..b410ea2
--- /dev/null
+++ b/src/test/resources/queries/bsp-paging.jsonld
@@ -0,0 +1,19 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:token", 
+    "wrap": {
+      "@type": "korap:term", 
+      "foundry": "mate",
+      "layer" : "lemma",
+      "key":"alphabet", 
+      "match": "match:eq"
+    }
+  },
+  "startPage":2,
+  "count": 5,
+  "context":{
+    "left":["char",90],
+    "right":["char",90]
+  }
+}
diff --git a/src/test/resources/queries/bsp1.jsonld b/src/test/resources/queries/bsp1.jsonld
index 100d9fa..36fb042 100644
--- a/src/test/resources/queries/bsp1.jsonld
+++ b/src/test/resources/queries/bsp1.jsonld
@@ -114,7 +114,7 @@
       }, 
       {
         "@type": "korap:group", 
-        "quantifier": "*", 
+	"min" : 0,
         "operation": "operation:repetition",
         "operands": [
           {
@@ -132,7 +132,7 @@
               {
                 "@type": "korap:token", 
                 "wrap": {
-                  "@type": "korap:term", 
+                  "@type": "korap:term",
                   "layer": "base",
                   "key" : "bar"
                 }
diff --git a/src/test/resources/queries/bsp10.jsonld b/src/test/resources/queries/bsp10.jsonld
index 19ad4a2..643edc3 100644
--- a/src/test/resources/queries/bsp10.jsonld
+++ b/src/test/resources/queries/bsp10.jsonld
@@ -108,7 +108,8 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
-          "layer": "base",
+	  "foundry" : "mate",
+          "layer": "lemma",
           "key" : "Katze"
         }
       }, 
diff --git a/src/test/resources/queries/bsp12.jsonld b/src/test/resources/queries/bsp12.jsonld
index b909da1..4db4b95 100644
--- a/src/test/resources/queries/bsp12.jsonld
+++ b/src/test/resources/queries/bsp12.jsonld
@@ -113,7 +113,8 @@
         "@type": "korap:token",
         "wrap" : {
           "@type": "korap:term", 
-          "layer": "base",
+          "foundry": "mate",
+          "layer": "lemma",
           "key" : "Mann"
         }
       }
diff --git a/src/test/resources/queries/bsp13b.jsonld b/src/test/resources/queries/bsp13b.jsonld
index f67adef..6a4b19e 100644
--- a/src/test/resources/queries/bsp13b.jsonld
+++ b/src/test/resources/queries/bsp13b.jsonld
@@ -113,9 +113,10 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
+	  "foundry" : "mate",
           "layer": "pos",
           "key" : "Det", 
-	      "match" : "match:ne"
+	  "match" : "match:eq"
         }
       }
     ]
diff --git a/src/test/resources/queries/bsp14.jsonld b/src/test/resources/queries/bsp14.jsonld
index ad6e7e3..f9c98e0 100644
--- a/src/test/resources/queries/bsp14.jsonld
+++ b/src/test/resources/queries/bsp14.jsonld
@@ -104,7 +104,8 @@
     "@type": "korap:token", 
     "wrap": {
       "@type" : "korap:term",
-      "type": "type:regex", 
+      "type": "type:regex",
+      "layer": "orth",
       "key": "vers{2,3}uch"
     }
   }
diff --git a/src/test/resources/queries/bsp16.jsonld b/src/test/resources/queries/bsp16.jsonld
index 778a01b..72586cb 100644
--- a/src/test/resources/queries/bsp16.jsonld
+++ b/src/test/resources/queries/bsp16.jsonld
@@ -112,12 +112,14 @@
           "operands": [
             {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry": "mate",
+              "layer": "lemma",
               "key" : "bar"
             }, 
             {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry": "mate",
+              "layer": "lemma",
               "key" : "foo"
             }
           ]
diff --git a/src/test/resources/queries/bsp17.jsonld b/src/test/resources/queries/bsp17.jsonld
index 5fe54e0..2df7268 100644
--- a/src/test/resources/queries/bsp17.jsonld
+++ b/src/test/resources/queries/bsp17.jsonld
@@ -113,7 +113,8 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
-          "layer": "base",
+	  "foundry" : "mate",
+          "layer": "lemma",
           "key" : "Mann"
         }
       }
diff --git a/src/test/resources/queries/bsp1b.jsonld b/src/test/resources/queries/bsp1b.jsonld
new file mode 100644
index 0000000..2a2631c
--- /dev/null
+++ b/src/test/resources/queries/bsp1b.jsonld
@@ -0,0 +1,64 @@
+{
+    "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+   "query":{
+      "@type":"korap:group",
+      "operation":"operation:or",
+      "operands":[
+         {
+            "@type":"korap:token",
+            "wrap":{
+               "@type":"korap:term",
+               "foundry":"mate",
+	      "layer" : "lemma",
+	      "key" :"foo",
+               "match":"match:eq"
+            }
+         },
+         {
+            "@type":"korap:group",
+           "operation":"operation:sequence",
+            "operands":[
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+		    "foundry" : "mate",
+                     "layer":"lemma",
+		    "key":"foo",
+                     "match":"match:eq"
+                  }
+               },
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+		    "foundry": "mate",
+                     "layer":"lemma",
+		    "key" : "bar",
+                     "match":"match:eq"
+                  }
+               }
+            ]
+         }
+      ]
+   },
+   "meta":{
+      "@type":"korap:meta",
+      "@value":{
+         "@type":"korap:group",
+         "operands":[
+            {
+               "@type":"korap:term",
+               "@value":"author:Goethe",
+               "relation":"="
+            },
+            {
+               "@type":"korap:term",
+               "@value":"year:1815",
+               "relation":"="
+            }
+         ],
+         "relation":"and"
+      }
+   }
+}
diff --git a/src/test/resources/queries/bsp2.jsonld b/src/test/resources/queries/bsp2.jsonld
index aa8673e..08ac500 100644
--- a/src/test/resources/queries/bsp2.jsonld
+++ b/src/test/resources/queries/bsp2.jsonld
@@ -112,7 +112,8 @@
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base", 
+	      "foundry": "mate", 
+              "layer": "lemma", 
               "key" : "foo"
             }
           }, 
@@ -120,7 +121,8 @@
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry": "mate", 
+              "layer": "lemma",
               "key" : "bar"
             }
           }
@@ -130,7 +132,8 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
-          "layer": "base",
+	  "foundry": "mate", 
+          "layer": "lemma",
           "key" : "foobar"
         }
       }
diff --git a/src/test/resources/queries/bsp3.jsonld b/src/test/resources/queries/bsp3.jsonld
index 642d91f..1a40038 100644
--- a/src/test/resources/queries/bsp3.jsonld
+++ b/src/test/resources/queries/bsp3.jsonld
@@ -114,7 +114,8 @@
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry" : "mate",
+              "layer": "lemma",
               "key" : "Mann"
             }
           }
diff --git a/src/test/resources/queries/bsp4.json b/src/test/resources/queries/bsp4.json
index c7ddb5b..138bdd4 100644
--- a/src/test/resources/queries/bsp4.json
+++ b/src/test/resources/queries/bsp4.json
@@ -26,7 +26,7 @@
                 "operands": [
                     {
                         "@type": "korap:group", 
-                        "class": "0", 
+                        "class": 0, 
                         "operands": [
                             {
                                 "@type": "korap:token", 
diff --git a/src/test/resources/queries/bsp4.jsonld b/src/test/resources/queries/bsp4.jsonld
index b64ef29..c5cc7db 100644
--- a/src/test/resources/queries/bsp4.jsonld
+++ b/src/test/resources/queries/bsp4.jsonld
@@ -111,13 +111,15 @@
         "operands": [
           {
             "@type": "korap:group", 
+	    "operation":"operation:class",
             "class": 0, 
             "operands": [
               {
                 "@type": "korap:token", 
                 "wrap": {
                   "@type": "korap:term", 
-                  "layer": "base",
+		  "foundry" : "mate",
+                  "layer": "lemma",
                   "key" : "foo"
                 }
               }
diff --git a/src/test/resources/queries/bsp5.jsonld b/src/test/resources/queries/bsp5.jsonld
index 1a12d6d..bebc438 100644
--- a/src/test/resources/queries/bsp5.jsonld
+++ b/src/test/resources/queries/bsp5.jsonld
@@ -106,25 +106,29 @@
     "classRef": [1],
     "operands": [
       {
-        "@type": "korap:sequence",
+        "@type": "korap:group",
+	"operation" : "operation:sequence",
         "operands": [
           {
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry" : "mate",
+              "layer": "lemma",
               "key" : "Der"
             }
           }, 
           {
             "@type": "korap:group", 
+	    "operation" : "operation:class",
             "class": 1, 
             "operands": [
               {
                 "@type": "korap:token", 
                 "wrap": {
                   "@type": "korap:term", 
-                  "layer": "base",
+                  "foundry": "mate",
+                  "layer": "lemma",
                   "key" : "Mann"
                 }
               }
diff --git a/src/test/resources/queries/bsp6.jsonld b/src/test/resources/queries/bsp6.jsonld
index fc9fe84..64e8d17 100644
--- a/src/test/resources/queries/bsp6.jsonld
+++ b/src/test/resources/queries/bsp6.jsonld
@@ -104,7 +104,8 @@
     "@type": "korap:token", 
     "wrap": {
       "@type": "korap:term", 
-      "layer": "base",
+      "foundry" : "mate",
+      "layer": "lemma",
       "key" : "Katze"
     }
   }
diff --git a/src/test/resources/queries/bsp7.jsonld b/src/test/resources/queries/bsp7.jsonld
index 074d2d3..46ab329 100644
--- a/src/test/resources/queries/bsp7.jsonld
+++ b/src/test/resources/queries/bsp7.jsonld
@@ -104,7 +104,8 @@
     "@type": "korap:token", 
     "wrap" : {
       "@type": "korap:term", 
-      "layer": "base",
+      "foundry": "mate",
+      "layer": "lemma",
       "key": "Katze", 
       "match": "match:ne"
     }
diff --git a/src/test/resources/queries/bsp9.jsonld b/src/test/resources/queries/bsp9.jsonld
index 41e9cfb..52f10b9 100644
--- a/src/test/resources/queries/bsp9.jsonld
+++ b/src/test/resources/queries/bsp9.jsonld
@@ -108,7 +108,8 @@
       "operands": [
         {
           "@type": "korap:term", 
-          "layer": "base",
+          "foundry": "mate",
+          "layer": "lemma",
           "key" : "Katze"
         }, 
         {
diff --git a/src/test/resources/queries/metaquery3.jsonld b/src/test/resources/queries/metaquery3.jsonld
new file mode 100644
index 0000000..0f7f3dd
--- /dev/null
+++ b/src/test/resources/queries/metaquery3.jsonld
@@ -0,0 +1,51 @@
+{
+    "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "startPage" : 2,
+    "count" : 5,
+    "context" : {
+      "left" : [ "token", 3 ],
+      "right" : [ "char", 6 ]
+    },
+   "query":{
+      "@type":"korap:group",
+      "operation":"operation:or",
+      "operands":[
+         {
+            "@type":"korap:token",
+            "wrap":{
+               "@type":"korap:term",
+	        "foundry" : "mate",
+               "layer":"l",
+	       "key":"Vokal",
+               "match":"match:eq"
+            }
+         },
+         {
+            "@type":"korap:group",
+	   "operation" : "operation:sequence",
+            "operands":[
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+		     "foundry" : "mate",
+                     "layer":"l",
+		     "key" : "der",
+                     "match":"match:eq"
+                  }
+               },
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+                     "foundry":"mate",
+		      "layer" : "p",
+		      "key" : "ADJA",
+                     "match":"match:eq"
+                  }
+               }
+            ]
+         }
+      ]
+   }
+}
diff --git a/src/test/resources/queries/metaquery4.jsonld b/src/test/resources/queries/metaquery4.jsonld
new file mode 100644
index 0000000..7da685d
--- /dev/null
+++ b/src/test/resources/queries/metaquery4.jsonld
@@ -0,0 +1,40 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "startPage" : 1,
+  "count" : 5,
+  "context" : {
+    "left" : [ "token", 3 ],
+    "right" : [ "char", 6 ]
+  },
+  "query":{
+    "@type":"korap:token",
+    "wrap":{
+      "@type":"korap:term",
+      "foundry":"mate",
+      "layer":"l",
+      "key":"lediglich",
+      "match":"match:eq"
+    }
+  },
+  "meta": [
+    {
+      "@type": "korap:meta-filter",
+      "@id": "korap-filter#id-1223232",
+      "@value": {
+        "@type": "korap:group",
+        "relation": "between",
+        "@field": "korap:field#pubDate",
+        "operands": [
+          {
+            "@type": "korap:date",
+            "@value": "2000-01-01"
+          },
+          {
+            "@type": "korap:date",
+            "@value": "2013-12-31"
+          }
+        ]
+      }
+    }
+  ]
+}
diff --git a/src/test/resources/queries/metaquery5.jsonld b/src/test/resources/queries/metaquery5.jsonld
new file mode 100644
index 0000000..497494e
--- /dev/null
+++ b/src/test/resources/queries/metaquery5.jsonld
@@ -0,0 +1,46 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "startPage" : 1,
+  "count" : 5,
+  "context" : {
+    "left" : [ "token", 3 ],
+    "right" : [ "char", 6 ]
+  },
+  "query":{
+    "@type":"korap:token",
+    "wrap":{
+      "@type":"korap:term",
+      "foundry": "mate",
+      "layer":"l",
+      "key":"lediglich",
+      "match":"match:eq"
+    }
+  },
+  "meta": [
+    {
+      "@type": "korap:meta-filter",
+      "@id": "korap-filter#id-1223232",
+      "@value": {
+	"@type": "korap:group",
+	"relation": "and",
+	"operands": [
+	  {
+            "@type": "korap:group",
+            "relation": "between",
+            "@field": "korap:field#pubDate",
+            "operands": [
+              {
+		"@type": "korap:date",
+		"@value": "2000-01-01"
+              },
+              {
+		"@type": "korap:date",
+		"@value": "2013-12-31"
+              }
+            ]
+	  }
+	]
+      }
+    }
+  ]
+}
diff --git a/src/test/resources/queries/metaquery6.jsonld b/src/test/resources/queries/metaquery6.jsonld
new file mode 100644
index 0000000..5acb266
--- /dev/null
+++ b/src/test/resources/queries/metaquery6.jsonld
@@ -0,0 +1,45 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "startPage" : 1,
+  "count" : 5,
+  "context" : {
+    "left" : [ "token", 3 ],
+    "right" : [ "char", 6 ]
+  },
+  "query":{
+    "@type":"korap:token",
+    "wrap":{
+      "@type":"korap:term",
+      "foundry":"mate",
+      "layer":"l",
+      "key":"lediglich"
+    }
+  },
+  "meta": [
+    {
+      "@type": "korap:meta-filter",
+      "@id": "korap-filter#id-1223232",
+      "@value": {
+	"@type": "korap:group",
+	"relation": "and",
+	"operands": [
+	  {
+            "@type": "korap:group",
+            "relation": "between",
+            "@field": "korap:field#pubDate",
+            "operands": [
+              {
+		"@type": "korap:date",
+		"@value": "2005-01-01"
+              },
+              {
+		"@type": "korap:date",
+		"@value": "2013-12-31"
+              }
+            ]
+	  }
+	]
+      }
+    }
+  ]
+}