testing / error msgs
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
index d3a9392..09c68c3 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
@@ -788,14 +788,14 @@
         LinkedHashMap<String, Object> fieldMap = null;
         // regex group #2 is foundry, #4 layer, #5 operator,
         // #6 key, #8 value
-        String wordOrRegex = "\\w+|\".*?\"";
+        String wordOrRegex = "\\w+|\".+?\"";
         Pattern p = Pattern
                 .compile("((\\w+)/)?((\\w*)(!?=))?("+wordOrRegex+")(:("+wordOrRegex+"))?");
         Matcher m;
         for (String morphterm : morphterms) {
             m = p.matcher(morphterm);
             if (!m.matches()) {
-                addError(StatusCodes.UNKNOWN_QUERY_ERROR,
+                addError(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
                         "Something went wrong parsing the argument in MORPH().");
                 requestMap.put("query", new LinkedHashMap<String, Object>());
                 return;
diff --git a/src/test/java/AnnisQueryProcessorTest.java b/src/test/java/AnnisQueryProcessorTest.java
index eb5a738..fffd806 100644
--- a/src/test/java/AnnisQueryProcessorTest.java
+++ b/src/test/java/AnnisQueryProcessorTest.java
@@ -10,6 +10,7 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
 
 /**
  * Tests for JSON-LD serialization of ANNIS QL queries. 
@@ -573,6 +574,13 @@
         assertEquals("D",                   res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key").asText());
         assertEquals("E",                   res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
         assertEquals("F",                   res.at("/query/operands/1/key").asText());
+        
+        query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & #1 . #2 & #3 . #4";  
+        // the resulting query should be equivalent to PQ+:  focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D> 
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals(true,         res.at("/query/@type").isMissingNode());
+        assertEquals(StatusCodes.UNBOUND_ANNIS_RELATION,   res.at("/errors/0/0").asInt());
     }
 	
 //	@Test
diff --git a/src/test/java/Cosmas2QueryProcessorTest.java b/src/test/java/Cosmas2QueryProcessorTest.java
index 56accbe..a65ec95 100644
--- a/src/test/java/Cosmas2QueryProcessorTest.java
+++ b/src/test/java/Cosmas2QueryProcessorTest.java
@@ -6,6 +6,7 @@
 import org.junit.Test;
 
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -141,7 +142,6 @@
         assertEquals("tt",                  res.at("/query/wrap/foundry").asText());
         assertEquals("match:eq",            res.at("/query/wrap/match").asText());
 
-		
 		query = "MORPH(mate/m=temp:pres)";
 		qs.setQuery(query, "cosmas2");
 		res = mapper.readTree(qs.toJSON());
@@ -1136,4 +1136,28 @@
 		assertEquals(131,							res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/classOut").asInt());
 		assertEquals("der",							res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key").asText());
 	}
+	
+	@Test
+	public void testErrors() throws JsonProcessingException, IOException {
+	    query = "MORPH(tt/p=\"\")";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals(true,         res.at("/query/@type").isMissingNode());
+        assertEquals(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,          res.at("/errors/0/0").asInt());
+        assertTrue(res.at("/errors/0/1").asText().startsWith("Something went wrong parsing the argument in MORPH()"));
+        
+        query = "MORPH(tt/p=\"foo)";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals(true,         res.at("/query/@type").isMissingNode());
+        assertEquals(StatusCodes.MALFORMED_QUERY,          res.at("/errors/0/0").asInt());
+        assertTrue(res.at("/errors/0/1").asText().startsWith("Early closing parenthesis"));
+        
+        query = "MORPH(tt/p=)";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals(true,         res.at("/query/@type").isMissingNode());
+        assertEquals(StatusCodes.MALFORMED_QUERY,          res.at("/errors/0/0").asInt());
+        assertTrue(res.at("/errors/0/1").asText().startsWith("Early closing parenthesis"));
+	}
 }
\ No newline at end of file
diff --git a/src/test/java/PoliqarpPlusQueryProcessorTest.java b/src/test/java/PoliqarpPlusQueryProcessorTest.java
index 309bdc6..97d5c8d 100644
--- a/src/test/java/PoliqarpPlusQueryProcessorTest.java
+++ b/src/test/java/PoliqarpPlusQueryProcessorTest.java
@@ -1215,6 +1215,29 @@
 		assertEquals("p",					res.at("/query/operands/1/wrap/layer").asText());
 		assertEquals("Baum",				res.at("/query/operands/2/wrap/key").asText());
 	}
-}
-
-
+	
+	@Test
+    public void testMeta() throws JsonProcessingException, IOException {
+        query = "x meta textClass=Sport";
+        qs.setQuery(query, "poliqarpplus");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("x",                   res.at("/query/wrap/key").asText());
+        assertEquals("korap:doc",           res.at("/collection/@type").asText());
+        assertEquals("textClass",           res.at("/collection/key").asText());
+        assertEquals("Sport",               res.at("/collection/value").asText());
+        
+        query = "x meta textClass=Sport";
+        qs.setQuery(query, "poliqarpplus");
+        qs.setCollection("author=Smith");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("x",                   res.at("/query/wrap/key").asText());
+        assertEquals("korap:docGroup",      res.at("/collection/@type").asText());
+        assertEquals("operation:and",       res.at("/collection/operation").asText());
+        assertEquals("textClass",           res.at("/collection/operands/0/key").asText());
+        assertEquals("Sport",               res.at("/collection/operands/0/value").asText());
+        assertEquals("author",              res.at("/collection/operands/1/key").asText());
+        assertEquals("Smith",               res.at("/collection/operands/1/value").asText());
+        
+        // TODO more tests
+	}
+}
\ No newline at end of file