bugfix poliqarp flags
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index 0d20174..51ec0f0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -213,6 +213,8 @@
             cqHasOccChild = false;
             // disregard empty segments in simple queries (parsed by ANTLR as empty cq_segments)
             ignoreCq_segment = (node.getChildCount() == 1 && (node.getChild(0).toStringTree(parser).equals(" ") || getNodeCat(node.getChild(0)).equals("spanclass") || getNodeCat(node.getChild(0)).equals("position")));
+//            ignoreCq_segment = ignoreCq_segment | (node.getParent().getChildCount()==2 && getNodeCat(node.getParent().getChild(1)).equals("flag"));
+            
 //            ignoreCq_segment = (node.getChildCount() == 1 && (node.getChild(0).toStringTree(parser).equals(" ") || getNodeCat(node.getChild(0)).equals("position")));
             // ignore this node if it only serves as an aligned sequence container
             if (node.getChildCount() > 1) {
@@ -490,6 +492,16 @@
             if (foundry != null) fieldMap.put("foundry", foundry);
 
             fieldMap.put("match", "match:" + relation);
+
+        	
+            if (hasChild(valNode.getChild(0), "flag")) {
+            	ParseTree flagNode = getFirstChildWithCat(valNode.getChild(0), "flag").getChild(0);
+            	String flag = getNodeCat(flagNode).substring(1); //substring removes leading slash '/'
+                // add to current token's value
+                if (flag.contains("i")) fieldMap.put("caseInsensitive", true);
+                else if (flag.contains("I")) fieldMap.put("caseInsensitive", false);
+                else fieldMap.put("flag", flag);
+            }
             // Step II: decide where to put the field map (as the only value of a token or the meta filter or as a part of a group in case of coordinated fields)
             if (fieldStack.isEmpty()) {
                 if (!inMeta) {
@@ -1004,7 +1016,11 @@
                 "[base=der] within s",
                 "([orth=der][base=katze])|([orth=eine][base=baum])",
                 "[orth=der][base=katze]|[orth=eine][base=baum]",
-                "shrink(1:{[base=der]}{1:[pos=ADJA]})"
+                "shrink(1:{[base=der]}{1:[pos=ADJA]})",
+                "[mate/m : tense=pres]",
+                "[cnx/base=pos:n]",
+                "deutscher/i",
+                "[orth=deutscher/i]"
         };
 		PoliqarpPlusTree.verbose=true;
         for (String q : queries) {
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index 23337db..9da4cfc 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -71,6 +71,23 @@
 		ppt = new PoliqarpPlusTree(query);
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		query="deutscher/i";
+		String cs3 = 
+				"{@type=korap:token, wrap={@type=korap:term, key=deutscher, layer=orth, match=match:eq, caseInsensitive=true}}";
+		ppt = new PoliqarpPlusTree(query);
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(cs3.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		query="deutscher/i Bundestag";
+		String cs4 = 
+				"{@type=korap:group, operation=operation:sequence, operands=[" +
+						"{@type=korap:token, wrap={@type=korap:term, key=deutscher, layer=orth, match=match:eq, caseInsensitive=true}}," +
+						"{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" +
+					"]}";
+		ppt = new PoliqarpPlusTree(query);
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(cs4.replaceAll(" ", ""), map.replaceAll(" ", ""));
 	}
 	
 	@Test
@@ -824,19 +841,19 @@
 		
 		
 		String shr8 = 
-				"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
-					"{@type=korap:group, operation=operation:sequence, operands=[" +
-						"{@type=korap:group, operation=operation:class, class=0, operands=[" +
-							"{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}" +
-						"]}," +
-						"{@type=korap:group, operation=operation:class, class=1, operands=[" +
-							"{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=pos, match=match:eq}}" +
-						"]}" +
+			"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+				"{@type=korap:group, operation=operation:sequence, operands=[" +
+					"{@type=korap:group, operation=operation:class, class=0, operands=[" +
+						"{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}" +
+					"]}," +
+					"{@type=korap:group, operation=operation:class, class=1, operands=[" +
+						"{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=pos, match=match:eq}}" +
 					"]}" +
-				"]}";
-			ppt = new PoliqarpPlusTree("shrink(1:{[base=der]}{1:[pos=ADJA]})");
-			map = ppt.getRequestMap().get("query").toString();
-			assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", ""));
+				"]}" +
+			"]}";
+		ppt = new PoliqarpPlusTree("shrink(1:{[base=der]}{1:[pos=ADJA]})");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 	}