Warn on use of operation:merge

Change-Id: Ib3764ebcff3222aa0bd18e28e6c3e1ff862bb170
diff --git a/Changes b/Changes
index 71704d4..90856b9 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.55.7 2017-01-13
+0.55.7 2017-01-24
         - [bugfix] Sorted results in unordered element distance query results (margaretha)
         - [bugfix] Throw error on optional operands in distance
           queries (diewald)
@@ -23,6 +23,7 @@
         - [bugfix] issue #16 (added skipTo in ElementDistanceSpan)
           (margaretha)
         - [bugfix] Fixed class ordering of highlights (diewald)
+        - [feature] warn on use of "operation:merge" (diewald)
 
 0.55.6 2016-08-10
         - [bugfix] distance with key "t" uses default foundry (diewald)
diff --git a/misc/errorcodes.md b/misc/errorcodes.md
index 0a01892..04bd64c 100644
--- a/misc/errorcodes.md
+++ b/misc/errorcodes.md
@@ -65,6 +65,7 @@
 771: "Arbitrary elements with attributes are currently not supported"
 772: "'Any' elements are currently not supported in position operations"
 773: "Negative elements are currently not supported in position operations"
+774: "Merge operation is currently not supported"
 780: "This query matches everywhere"
 781: "Optionality of query is ignored"
 782: "Exclusivity of query is ignored"
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index 45f1dda..3cfd7ee 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -442,6 +442,11 @@
                 /*throw new QueryException(765,
                   "Relations are currently not supported");*/
 
+			// Gracefully warn on merge support
+			case "operation:merge":
+				this.addWarning(774, "Merge operation is currently not supported");
+				return _fromKoral(operands.get(0));
+				
                 // Deprecated in favor of operation:junction
             case "operation:or":
                 return this._operationJunctionFromJson(operands);
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
index af53472..34fb3f1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
@@ -601,18 +601,20 @@
 
 
     @Test
-    public void queryJSONregexRewrite2 () throws QueryException {
-        // "der" [.*] [.*?] [.+] [.+?]
+    public void queryJSONmerge () throws QueryException {
+        // treat merging gracefully
         String json = getString(getClass()
-                .getResource("/queries/sequence/regex-rewrite-2.jsonld")
+                .getResource("/queries/merge.jsonld")
                 .getFile());
         KrillQuery kq = new KrillQuery("tokens");
-
         assertEquals(kq.fromKoral(json).toQuery().toString(),
-                "focus(254: spanContain(<tokens:base/s:t />, {254: spanExpansion(tokens:s:der, []{4, 4}, right)}))");
+                "spanNext(tokens:s:der, tokens:s:Baum)");
+		assertEquals(kq.getWarning(0).getCode(), 774);
     };
 
 
+	
+
     public static String getString (String path) {
         StringBuilder contentBuilder = new StringBuilder();
         try {
diff --git a/src/test/resources/queries/merge.jsonld b/src/test/resources/queries/merge.jsonld
new file mode 100644
index 0000000..9b50760
--- /dev/null
+++ b/src/test/resources/queries/merge.jsonld
@@ -0,0 +1,34 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+  "query": {
+    "@type": "koral:group",
+    "operation":"operation:merge",
+    "operands": [
+      {
+        "@type": "koral:group",
+        "operation": "operation:sequence",
+        "inOrder": true,
+        "operands": [
+          {
+            "@type": "koral:token",
+            "wrap": {
+              "match": "match:eq",
+              "layer": "orth",
+              "key": "der",
+              "@type": "koral:term"
+            }
+          },
+          {
+            "wrap": {
+              "match": "match:eq",
+              "layer": "orth",
+              "key": "Baum",
+              "@type": "koral:term"
+            },
+            "@type": "koral:token"
+          }
+        ]
+      }
+    ]
+  }
+}