Nested meta now working
diff --git a/CHANGES b/CHANGES
index 26c5611..d24996c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,7 @@
 0.26.2 2014-02-12
         - Added sequence queries with defined gaps (margaretha)
 	- Support for multiple distance constraints (margaretha)
-	- Updated json-ld serialization (diewald)
+	- Updated json-ld deserialization with nested meta (diewald)
 	- [bugfix] Wildcards in segments were ignored (diewald)
 
 0.26.1 2014-01-21
diff --git a/src/main/java/de/ids_mannheim/korap/KorapCollection.java b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
index c41d7f9..ef01c9c 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
@@ -59,10 +59,10 @@
 	ObjectMapper mapper = new ObjectMapper();
 	try {
 	    JsonNode json = mapper.readValue(jsonString, JsonNode.class);
-	    if (json.has("meta")) {
+	    if (json.has("collections")) {
 		log.trace("Add meta collection");
-		for (JsonNode meta : json.get("meta")) {
-		    this.fromJSON(meta);
+		for (JsonNode collection : json.get("collections")) {
+		    this.fromJSON(collection);
 		};
 	    };
 	}
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index ae3f70f..30895fe 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -115,35 +115,38 @@
 	    };
 
 	    // "meta" virtual collections
-	    if (json.has("meta"))
+	    if (json.has("collections"))
 		this.setCollection(new KorapCollection(jsonString));
 
 	    if (this.error == null) {
+		if (json.has("meta")) {
+		    JsonNode meta = json.get("meta");
 
-		// Defined count
-		if (json.has("count"))
-		    this.setCount(json.get("count").asInt());
+		    // Defined count
+		    if (meta.has("count"))
+			this.setCount(meta.get("count").asInt());
 
-		// Defined startIndex
-		if (json.has("startIndex"))
-		    this.setStartIndex(json.get("startIndex").asInt());
+		    // Defined startIndex
+		    if (meta.has("startIndex"))
+			this.setStartIndex(meta.get("startIndex").asInt());
 
-		// Defined startPage
-		if (json.has("startPage"))
-		    this.setStartPage(json.get("startPage").asInt());
+		    // Defined startPage
+		    if (meta.has("startPage"))
+			this.setStartPage(meta.get("startPage").asInt());
 
-		// Defined cutOff
-		if (json.has("cutOff"))
-		    this.setCutOff(json.get("cutOff").asBoolean());
+		    // Defined cutOff
+		    if (meta.has("cutOff"))
+			this.setCutOff(meta.get("cutOff").asBoolean());
 
-		// Defined contexts
-		if (json.has("context")) {
-		    JsonNode context = json.get("context");
-		    if (context.has("left"))
-			this.leftContext.fromJSON(context.get("left"));
+		    // Defined contexts
+		    if (meta.has("context")) {
+			JsonNode context = meta.get("context");
+			if (context.has("left"))
+			    this.leftContext.fromJSON(context.get("left"));
 
-		    if (context.has("right"))
-			this.rightContext.fromJSON(context.get("right"));
+			if (context.has("right"))
+			    this.rightContext.fromJSON(context.get("right"));
+		    };
 		};
 	    };
 	}
diff --git a/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollectionJSON.java b/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollectionJSON.java
index 87e20ff..4296da4 100644
--- a/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollectionJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollectionJSON.java
@@ -14,7 +14,7 @@
 
     @Test
     public void metaQuery1 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery.json").getFile());
+	String metaQuery = getString(getClass().getResource("/queries/metaquery.jsonld").getFile());
 	KorapCollection kc = new KorapCollection(metaQuery);
 
 	assertEquals("filter with QueryWrapperFilter(+textClass:wissenschaft)", kc.getFilter(0).toString());
@@ -26,7 +26,7 @@
 
     @Test
     public void metaQuery2 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery2.json").getFile());
+	String metaQuery = getString(getClass().getResource("/queries/metaquery2.jsonld").getFile());
 	KorapCollection kc = new KorapCollection(metaQuery);
 	assertEquals(1,kc.getCount());
 	assertEquals("filter with QueryWrapperFilter(+author:Hesse +pubDate:[0 TO 20131205])",kc.getFilter(0).toString());
@@ -34,7 +34,7 @@
 
     @Test
     public void metaQuery3 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery4.json").getFile());
+	String metaQuery = getString(getClass().getResource("/queries/metaquery4.jsonld").getFile());
 	KorapCollection kc = new KorapCollection(metaQuery);
 	assertEquals(1,kc.getCount());
 	assertEquals("filter with QueryWrapperFilter(+pubDate:[20000101 TO 20131231])",kc.getFilter(0).toString());
diff --git a/src/test/resources/queries/bsp-class.jsonld b/src/test/resources/queries/bsp-class.jsonld
index f036535..075f927 100644
--- a/src/test/resources/queries/bsp-class.jsonld
+++ b/src/test/resources/queries/bsp-class.jsonld
@@ -33,4 +33,5 @@
       }
     ]
   },
-  "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]}}
+  "collections":[{"@type":"korap:meta-filter","@value":{"@type":"korap:term","@field":"korap:field#corpusID","@value":"WPD"}}],
+  "meta":{"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
index 576d2f6..605811a 100644
--- a/src/test/resources/queries/bsp-context-2.jsonld
+++ b/src/test/resources/queries/bsp-context-2.jsonld
@@ -1,4 +1,5 @@
-{"@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
  "query":{
    "@type":"korap:token",
    "wrap":{
@@ -9,7 +10,7 @@
      "match":"match:eq"
    }
  },
- "meta":[
+ "collections":[
    {
      "@type":"korap:meta-filter",
      "@value":{
@@ -19,6 +20,8 @@
      }
    }
  ],
+  "meta":{
  "startPage":1,
  "count":25,
  "context":{"left":["char",210],"right":["char",210]},"cutOff":true}
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/bsp-context.jsonld b/src/test/resources/queries/bsp-context.jsonld
index 327b8be..cd1ed3e 100644
--- a/src/test/resources/queries/bsp-context.jsonld
+++ b/src/test/resources/queries/bsp-context.jsonld
@@ -10,8 +10,10 @@
       "match": "match:eq"
     }
   },
-  "context":{
-    "left":["char",90],
-    "right":["char",90]
-  }
+  "meta":{
+    "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
index fea64b8..6c8da96 100644
--- a/src/test/resources/queries/bsp-cutoff.jsonld
+++ b/src/test/resources/queries/bsp-cutoff.jsonld
@@ -10,11 +10,13 @@
       "match": "match:eq"
     }
   },
-  "startPage":2,
-  "count": 2,
-  "cutOff": true,
-  "context":{
-    "left":["char",90],
-    "right":["char",90]
-  }
+  "meta":{
+    "startPage":2,
+    "count": 2,
+    "cutOff": true,
+    "context":{	     
+     "left":["char",90],
+      "right":["char",90]
+      }
+}
 }
diff --git a/src/test/resources/queries/bsp-fail1.jsonld b/src/test/resources/queries/bsp-fail1.jsonld
index d39a792..7425bc1 100644
--- a/src/test/resources/queries/bsp-fail1.jsonld
+++ b/src/test/resources/queries/bsp-fail1.jsonld
@@ -21,5 +21,7 @@
             }
         ], 
     },
+  "meta":{
     "startIndex": -2
+  }
 }
diff --git a/src/test/resources/queries/bsp-fail2.jsonld b/src/test/resources/queries/bsp-fail2.jsonld
index 417083e..dc4ace2 100644
--- a/src/test/resources/queries/bsp-fail2.jsonld
+++ b/src/test/resources/queries/bsp-fail2.jsonld
@@ -23,6 +23,8 @@
       }
     ]
   },
-  "count": 100,
-  "startPage": 1000
+  "meta":{
+    "count": 100,
+    "startPage": 1000
+  }
 }
diff --git a/src/test/resources/queries/bsp-paging.jsonld b/src/test/resources/queries/bsp-paging.jsonld
index b410ea2..9e258cc 100644
--- a/src/test/resources/queries/bsp-paging.jsonld
+++ b/src/test/resources/queries/bsp-paging.jsonld
@@ -10,10 +10,12 @@
       "match": "match:eq"
     }
   },
-  "startPage":2,
-  "count": 5,
-  "context":{
-    "left":["char",90],
-    "right":["char",90]
+  "meta":{
+    "startPage":2,
+    "count": 5,
+    "context":{
+      "left":["char",90],
+      "right":["char",90]
+    }
   }
 }
diff --git a/src/test/resources/queries/bsp1b.jsonld b/src/test/resources/queries/bsp1b.jsonld
index 2a2631c..4cec26c 100644
--- a/src/test/resources/queries/bsp1b.jsonld
+++ b/src/test/resources/queries/bsp1b.jsonld
@@ -42,7 +42,7 @@
          }
       ]
    },
-   "meta":{
+   "poliqarp-meta":{
       "@type":"korap:meta",
       "@value":{
          "@type":"korap:group",
diff --git a/src/test/resources/queries/metaquery.jsonld b/src/test/resources/queries/metaquery.jsonld
new file mode 100644
index 0000000..5b2ae44
--- /dev/null
+++ b/src/test/resources/queries/metaquery.jsonld
@@ -0,0 +1,115 @@
+{
+    "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "meta" : {
+      "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" : "lemma",
+	      "key" : "Vokal",
+               "match":"match:eq"
+            }
+         },
+         {
+            "@type":"korap:group",
+	   "operation": "operation:sequence",
+            "operands":[
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                    "@type":"korap:term",
+                    "foundry":"mate",
+		    "layer" : "base",
+		    "key" : "der",
+                    "match":"match:eq"
+                  }
+               },
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+                     "foundry":"mate",
+		      "layer" : "pos",
+		      "key" : "ADJA",
+                     "match":"match:eq"
+                  }
+               }
+            ]
+         }
+      ]
+   },
+    "collections": [
+        {
+            "@type": "korap:meta-filter",
+            "@id": "korap-filter#id-1223232",
+            "@value": {
+                "@type": "korap:term",
+                "@field": "korap:field#textClass",
+                "@value": "wissenschaft"
+            }
+        },
+        {
+            "@type": "korap:meta-filter",
+            "@id": "korap-filter#id-34345454",
+            "@value": {
+                "@type": "korap:group",
+                "relation": "and",
+                "operands": [
+                    {
+                        "@type": "korap:term",
+                        "@field": "korap:field#pubPlace",
+                        "@value": "Erfurt"
+                    },
+                    {
+                        "@type": "korap:term",
+                        "@field": "korap:field#author",
+                        "@value": "Hesse"
+                    }
+                ]
+            }
+        },
+        {
+            "@type": "korap:meta-extend",
+            "@value": {
+                "@type": "korap:group",
+                "relation": "and",
+                "operands": [
+                    {
+                        "@type": "korap:group",
+                        "comment": "other values can be 'since','until' in combination with a simple korap:term",
+                        "relation": "between",
+                        "field": "korap:field#pubDate",
+                        "operands": [
+                            {
+                                "@type": "korap:date",
+                                "comment": "either long value or String representation '2013-04-29'",
+                                "@value": "2011-04-29"
+                            },
+                            {
+                                "@type": "korap:date",
+                                "@value": "2013-12-31"
+                            }
+                        ]
+                    },
+                    {
+                        "@type": "korap:term",
+                        "@field": "korap:field#textClass",
+                        "@value": "freizeit"
+                    }
+                ]
+            }
+        }
+    ]
+}
diff --git a/src/test/resources/queries/metaquery2.jsonld b/src/test/resources/queries/metaquery2.jsonld
new file mode 100644
index 0000000..e1d4690
--- /dev/null
+++ b/src/test/resources/queries/metaquery2.jsonld
@@ -0,0 +1,80 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "meta":{
+    "startPage" : 2,
+    "count" : 5,
+    "context" : {
+      "left" : [ "token", 6 ],
+      "right" : [ "token", 6 ]
+    }
+  },
+  "query":{
+    "@type":"korap:group",
+    "operation":"operation:or",
+    "operands":[
+      {
+        "@type":"korap:token",
+        "wrap":{
+          "@type":"korap:term",
+          "foundry":"mate",
+	  "layer" : "lemma",
+	  "key" : "Vokal",
+          "match":"match:eq"
+        }
+      },
+      {
+        "@type":"korap:group",
+	"operation" : "operation:sequence",
+        "operands":[
+          {
+            "@type":"korap:token",
+            "wrap":{
+              "@type":"korap:term",
+              "foundry":"mate",
+	      "layer" : "lemma",
+	      "key" : "der",
+              "match":"match:eq"
+            }
+          },
+          {
+            "@type":"korap:token",
+            "wrap":{
+              "@type":"korap:term",
+              "foundry":"mate",
+	      "layer" : "p",
+	      "key" : "ADJD",
+              "match":"match:eq"
+            }
+          }
+        ]
+      }
+    ]
+  },
+  "collections": [
+    {
+      "@type": "korap:meta-filter",
+      "@value": {
+        "@type": "korap:group",
+        "relation": "and",
+        "operands": [
+          {
+            "@type": "korap:term",
+            "@field": "korap:field#author",
+            "@value": "Hesse"
+          },
+          {
+            "@type": "korap:group",
+            "@field": "korap:field#pubDate",
+            "relation": "until",
+            "operands": [
+              {
+                "@type": "korap:date",
+                "@value": "2013-12-05"
+              }
+            ]
+          }
+        ]
+      }
+    }
+  ]
+}
diff --git a/src/test/resources/queries/metaquery3.jsonld b/src/test/resources/queries/metaquery3.jsonld
index 0f7f3dd..adedda0 100644
--- a/src/test/resources/queries/metaquery3.jsonld
+++ b/src/test/resources/queries/metaquery3.jsonld
@@ -1,11 +1,13 @@
 {
     "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "meta":{
     "startPage" : 2,
     "count" : 5,
     "context" : {
       "left" : [ "token", 3 ],
       "right" : [ "char", 6 ]
-    },
+    }
+},
    "query":{
       "@type":"korap:group",
       "operation":"operation:or",
diff --git a/src/test/resources/queries/metaquery4.jsonld b/src/test/resources/queries/metaquery4.jsonld
index 7da685d..3fe71ed 100644
--- a/src/test/resources/queries/metaquery4.jsonld
+++ b/src/test/resources/queries/metaquery4.jsonld
@@ -1,10 +1,12 @@
 {
   "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
-  "startPage" : 1,
-  "count" : 5,
-  "context" : {
-    "left" : [ "token", 3 ],
-    "right" : [ "char", 6 ]
+  "meta":{
+    "startPage" : 1,
+    "count" : 5,
+    "context" : {
+      "left" : [ "token", 3 ],
+      "right" : [ "char", 6 ]
+    }
   },
   "query":{
     "@type":"korap:token",
@@ -16,7 +18,7 @@
       "match":"match:eq"
     }
   },
-  "meta": [
+  "collections": [
     {
       "@type": "korap:meta-filter",
       "@id": "korap-filter#id-1223232",
diff --git a/src/test/resources/queries/metaquery5.jsonld b/src/test/resources/queries/metaquery5.jsonld
index 497494e..7fc5b85 100644
--- a/src/test/resources/queries/metaquery5.jsonld
+++ b/src/test/resources/queries/metaquery5.jsonld
@@ -1,10 +1,12 @@
 {
   "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
-  "startPage" : 1,
-  "count" : 5,
-  "context" : {
-    "left" : [ "token", 3 ],
-    "right" : [ "char", 6 ]
+  "meta":{
+    "startPage" : 1,
+    "count" : 5,
+    "context" : {
+      "left" : [ "token", 3 ],
+      "right" : [ "char", 6 ]
+    }
   },
   "query":{
     "@type":"korap:token",
@@ -16,7 +18,7 @@
       "match":"match:eq"
     }
   },
-  "meta": [
+  "collections": [
     {
       "@type": "korap:meta-filter",
       "@id": "korap-filter#id-1223232",
diff --git a/src/test/resources/queries/metaquery6.jsonld b/src/test/resources/queries/metaquery6.jsonld
index 5acb266..0e4c30f 100644
--- a/src/test/resources/queries/metaquery6.jsonld
+++ b/src/test/resources/queries/metaquery6.jsonld
@@ -1,10 +1,12 @@
 {
   "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
-  "startPage" : 1,
-  "count" : 5,
-  "context" : {
-    "left" : [ "token", 3 ],
-    "right" : [ "char", 6 ]
+  "meta":{
+    "startPage" : 1,
+    "count" : 5,
+    "context" : {
+      "left" : [ "token", 3 ],
+      "right" : [ "char", 6 ]
+    }
   },
   "query":{
     "@type":"korap:token",
@@ -15,7 +17,7 @@
       "key":"lediglich"
     }
   },
-  "meta": [
+  "collections": [
     {
       "@type": "korap:meta-filter",
       "@id": "korap-filter#id-1223232",