Merge "Fixed the argument handler in the Indexer."
diff --git a/Changes b/Changes
index 47f9b2f..eb05c00 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.55.7 2016-10-14
+0.55.7 2016-11-06
         - [bugfix] Throw error on optional operands in distance
           queries (diewald)
         - [performance] Remember solved problematic queries in the
@@ -10,6 +10,9 @@
           a single extension, if possible (diewald)
         - [bugfix] Fixed paths in test suite for supporting
           spaces (margaretha)
+        - [bugfix] Warn on empty elements in positional queries (diewald)
+        - [bugfix] Fix wrong deserialization test with negative element in
+          positional queries (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 1ef94c6..0a01892 100644
--- a/misc/errorcodes.md
+++ b/misc/errorcodes.md
@@ -8,6 +8,7 @@
 603: "Unable to commit staged data to index"
 604: "Unable to connect to database"
 610: "Missing request parameters"
+613: Arbitrary deserialization error
 620: "Unable to generate JSON"
 621: "Unable to parse JSON"
 630: "Document not found"
@@ -62,6 +63,8 @@
 769: "Overlap variant currently interpreted as overlap"
 770: "Arity attributes are currently not supported - results may not be correct"
 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"
 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/query/wrap/SpanWithinQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
index 576b1e0..ceb58f2 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
@@ -96,6 +96,15 @@
 
         // TODO: if (wrap.isNegative())
 
+		if (this.element.isEmpty() || this.wrap.isEmpty()) {
+			throw new QueryException(772, "'Any' elements are currently not supported in position operations");
+		};
+
+		if (this.element.isNegative() || this.wrap.isNegative()) {
+			throw new QueryException(773, "Negative elements are currently not supported in position operations");
+		};
+		
+		
         return new SpanWithinQuery(
                 this.element.retrieveNode(this.retrieveNode).toFragmentQuery(),
                 this.wrap.retrieveNode(this.retrieveNode).toFragmentQuery(),
@@ -118,7 +127,7 @@
 
     @Override
     public boolean isNegative () {
-        if (this.element.isNegative())
+        if (this.element.isNegative() || this.wrap.isNegative())
             return true;
         return false;
     };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java
index 24f296c..829167f 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java
@@ -4,7 +4,9 @@
 import de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper;
 import de.ids_mannheim.korap.query.SpanWithinQuery;
 import de.ids_mannheim.korap.query.SpanElementQuery;
+import de.ids_mannheim.korap.query.QueryBuilder;
 
+import org.apache.lucene.search.spans.SpanQuery;
 import de.ids_mannheim.korap.util.QueryException;
 
 import static org.junit.Assert.*;
@@ -47,4 +49,17 @@
                 "spanStartsWith(<field:s />, spanNext(spanNext(field:a, field:b), field:c))",
                 ssequery.toString());
     };
+
+	@Test
+    public void spanSegmentStartsWithEmptyQuery () {
+
+		QueryBuilder qb = new QueryBuilder("field1");
+		
+		try {
+			SpanQuery sq = qb.startswith(qb.tag("base/s"), qb.empty()).toQuery();
+		}
+		catch (QueryException qe) {
+			assertEquals(qe.getErrorCode(), 772);
+		};
+    };
 };
diff --git a/src/test/resources/queries/bsp13.jsonld b/src/test/resources/queries/bsp13.jsonld
index e7659aa..9e3d1c8 100644
--- a/src/test/resources/queries/bsp13.jsonld
+++ b/src/test/resources/queries/bsp13.jsonld
@@ -15,7 +15,7 @@
           "@type": "koral:term", 
           "layer": "pos",
           "key" : "Det", 
-          "match" : "match:ne"
+          "match" : "match:eq"
         }
       }
     ]