Fixing resource bug and adding sorting requirement flag to SpanWrapQueries
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
index 28e9c72..e60ca21 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
@@ -104,18 +104,25 @@
         return this;
     };
 
+    @Override
     public SpanQuery toQuery() throws QueryException {
         if (this.isNull || this.alternatives.size() == 0)
             return (SpanQuery) null;
 	    
         if (this.alternatives.size() == 1) {
-            return (SpanQuery) this.alternatives.get(0).toQuery();
+            return (SpanQuery) this.alternatives.get(0).
+                retrieveNode(this.retrieveNode).
+                toQuery();
         };
 
         Iterator<SpanQueryWrapper> clause = this.alternatives.iterator();
-        SpanOrQuery soquery = new SpanOrQuery( clause.next().toQuery() );
+        SpanOrQuery soquery = new SpanOrQuery(
+            clause.next().retrieveNode(this.retrieveNode).toQuery()
+        );
         while (clause.hasNext()) {
-            soquery.addClause( clause.next().toQuery() );
+            soquery.addClause(
+                clause.next().retrieveNode(this.retrieveNode).toQuery()
+            );
         };
         return (SpanQuery) soquery;
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
index 52e2036..07ca212 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
@@ -24,7 +24,7 @@
     @Override
     public SpanQuery toQuery() throws QueryException {
 
-        SpanQuery sq = subquery.toQuery();
+        SpanQuery sq = subquery.retrieveNode(this.retrieveNode).toQuery();
         if (sq instanceof SpanTermQuery) {
             return new SpanAttributeQuery((SpanTermQuery) sq, isNegation, true);
         }
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
index a10670a..96c9a3b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
@@ -66,7 +66,7 @@
 		if (this.subquery.isNull())
             return (SpanQuery) null;
 
-        SpanQuery sq = (SpanQuery) this.subquery.toQuery();
+        SpanQuery sq = (SpanQuery) this.subquery.retrieveNode(this.retrieveNode).toQuery();
 
         if (sq == null) return (SpanQuery) null;
 	
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java
index 26853db..c12f1dd 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java
@@ -6,6 +6,14 @@
 import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import de.ids_mannheim.korap.util.QueryException;
 
+/*
+ * SpanElementQuery has to support two constructors:
+ * One respecting and adding node information to the payload,
+ * one ignoring node information.
+ * node aka depth in a tree information is only relevant for
+ * child relation queries.
+ */
+
 public class SpanElementQueryWrapper extends SpanQueryWrapper {
     String element;
     String field;
@@ -15,10 +23,15 @@
         this.element = element;
     };
 
+
+    @Override
     public SpanQuery toQuery () throws QueryException {
+        // Todo: Respect request for retrieving node data (i.e. depth information)
         return (SpanQuery) new SpanElementQuery(this.field, this.element);
     };
 
+
+    @Override
     public boolean isNull () {
         return false;
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java
index 4c57320..f9cafc9 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java
@@ -45,9 +45,11 @@
     };
 
     public SpanQuery toQuery () throws QueryException {
-	if (this.subquery.isNull())
-	    return (SpanQuery) null;
-	return new SpanMatchModifyClassQuery(this.subquery.toQuery(), this.number);
+        if (this.subquery.isNull())
+            return (SpanQuery) null;
+        return new SpanMatchModifyClassQuery(
+            this.subquery.retrieveNode(this.retrieveNode).toQuery(), this.number
+        );
     };
 
     public boolean isOptional () {
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
index 7ed43eb..5247ac4 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
@@ -34,7 +34,8 @@
         isEmpty    = false,
         isExtended = false,
         isExtendedToTheRight = false,
-        maybeUnsorted = false;
+        maybeUnsorted = false,
+        retrieveNode = false;
 
     /**
      * Serialize the wrapped query and return a SpanQuery.
@@ -283,6 +284,20 @@
 
 
     /**
+     * Make the query request node information in addition to
+     * span information.
+     *
+     * @param retrieve Boolean value saying the wrapper
+     *        has or has not to respect node information.
+     * @return The {@link SpanQueryWrapper} object for chaining.
+     */
+    public SpanQueryWrapper retrieveNode (boolean retrieve) {
+        this.retrieveNode = retrieve;
+        return this;
+    };
+
+
+    /**
      * Boolean value indicating that a wrapped query
      * has a class. This is especially relevant for classed
      * extension queries.
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
index 3e829be..8785098 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
@@ -91,11 +91,11 @@
 
         // The query is not a repetition query at all, but may be optional
         if (this.min == 1 && this.max == 1)
-            return this.subquery.toQuery();
+            return this.subquery.retrieveNode(this.retrieveNode).toQuery();
 
         // That's a fine repetition query
         return new SpanRepetitionQuery(
-            this.subquery.toQuery(),
+            this.subquery.retrieveNode(this.retrieveNode).toQuery(),
             this.min,
             this.max,
             true
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
index e3cc0d2..97cb24f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
@@ -481,7 +481,7 @@
         try {
             this.constraints.add(
                 new DistanceConstraint(
-                    (SpanElementQuery) unit.toQuery(),
+                    (SpanElementQuery) unit.retrieveNode(this.retrieveNode).toQuery(),
                     min,
                     max,
                     isInOrder,
@@ -612,7 +612,7 @@
 
             // Unproblematic single query
             if (this.segments.get(0).maybeAnchor())
-                return (SpanQuery) this.segments.get(0).toQuery();
+                return (SpanQuery) this.segments.get(0).retrieveNode(this.retrieveNode).toQuery();
 
             if (this.segments.get(0).isEmpty())
                 throw new QueryException(
@@ -653,7 +653,7 @@
         SpanQuery query = null;// = this.segments.get(0).toQuery();
         int i = 0;
         while (query == null && i < this.segments.size()) {
-            query = this.segments.get(i).toQuery();
+            query = this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
             i++;
         };
 
@@ -664,7 +664,7 @@
         if (!this.hasConstraints() && this.isInOrder()) {
             for (; i < this.segments.size(); i++) {
 
-                SpanQuery second = this.segments.get(i).toQuery();
+                SpanQuery second = this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
                 if (second == null)
                     continue;
 
@@ -688,7 +688,7 @@
                     if (this.segments.get(i).isExtended())
                         throw new QueryException(613, limitationError);
 
-                    SpanQuery sq = (SpanQuery) this.segments.get(i).toQuery();
+                    SpanQuery sq = (SpanQuery) this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
                     if (sq == null) continue;
 
                     SpanDistanceQuery sdquery = new SpanDistanceQuery(
@@ -709,7 +709,7 @@
                     if (this.segments.get(i).isExtended())
                         throw new QueryException(613, limitationError);
 
-                    SpanQuery sq = (SpanQuery) this.segments.get(i).toQuery();
+                    SpanQuery sq = (SpanQuery) this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
                     if (sq == null) continue;
                     
                     SpanDistanceQuery sdquery = new SpanDistanceQuery(
@@ -732,7 +732,7 @@
             if (this.segments.get(i).isExtended())
                 throw new QueryException(613, limitationError);
 
-            SpanQuery sq = (SpanQuery) this.segments.get(i).toQuery();
+            SpanQuery sq = (SpanQuery) this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
             if (sq == null) continue;
 
             query = new SpanMultipleDistanceQuery(
@@ -889,7 +889,7 @@
                           problem.getClassNumber());
 
             query = new SpanExpansionQuery(
-                anchor.toQuery(),
+                anchor.retrieveNode(this.retrieveNode).toQuery(),
                 problem.getMin(),
                 problem.getMax(),
                 direction,
@@ -909,8 +909,8 @@
                           problem.getClassNumber());
 
             query = new SpanExpansionQuery(
-                anchor.toQuery(),
-                problem.toQuery(),
+                anchor.retrieveNode(this.retrieveNode).toQuery(),
+                problem.retrieveNode(this.retrieveNode).toQuery(),
                 problem.getMin(),
                 problem.getMax(),
                 direction,
@@ -935,10 +935,10 @@
 
         // [base=der][base=baum]
         if (mergeLeft)
-            ssqw.append(new SpanSimpleQueryWrapper(problem.toQuery()));
+            ssqw.append(new SpanSimpleQueryWrapper(problem.retrieveNode(this.retrieveNode).toQuery()));
         // [base=baum][base=der]
         else
-            ssqw.prepend(new SpanSimpleQueryWrapper(problem.toQuery()));
+            ssqw.prepend(new SpanSimpleQueryWrapper(problem.retrieveNode(this.retrieveNode).toQuery()));
 	
         saqw.or(ssqw);
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
index c907f5a..1b3d160 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
@@ -108,7 +108,7 @@
 			return null;
 		}
 
-		SpanQuery sq = subquery.toQuery();
+		SpanQuery sq = subquery.retrieveNode(this.retrieveNode).toQuery();
 		if (sq == null)
 			return null;
 		if (sq instanceof SpanTermQuery) {
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 bb15807..a04b33a 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
@@ -93,7 +93,11 @@
 	
         // TODO: if (wrap.isNegative())
 
-        return new SpanWithinQuery(this.element.toQuery(), this.wrap.toQuery(), this.flag);
+        return new SpanWithinQuery(
+            this.element.retrieveNode(this.retrieveNode).toQuery(),
+            this.wrap.retrieveNode(this.retrieveNode).toQuery(),
+            this.flag
+        );
     };
 
 
diff --git a/src/main/resources/index.properties b/src/main/resources/index.properties
deleted file mode 100644
index 1c87567..0000000
--- a/src/main/resources/index.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-lucene.version = ${project.version}
-lucene.name = ${project.name}
-lucene.index.commit.count = 134217000
-lucene.index.commit.log = log/korap.commit.log
-lucene.indexDir = /home/ndiewald/Repositories/korap/KorAP-modules/KorAP-lucene-index/sandbox/index-tanja
diff --git a/src/main/resources/server.properties.info b/src/main/resources/server.properties.info
index 2a392e8..f35a016 100644
--- a/src/main/resources/server.properties.info
+++ b/src/main/resources/server.properties.info
@@ -1,3 +1,6 @@
+lucene.version = ${project.version}
+lucene.name = ${project.name}
+
 # Lucene Backend properties
 lucene.properties   = true
 lucene.indexDir     = [PATH TO INDEX DIRECTORY]
@@ -9,3 +12,6 @@
 lucene.db.URL       = jdbc:mysql://[DB_IP]:[DB_PORT]/[DB_NAME]
 lucene.db.pwd       = [DB_PWD]
 lucene.db.user      = [DB_USER]
+
+lucene.index.commit.count = 134217000
+lucene.index.commit.log = log/korap.commit.log