Fixed bug in JSON response where request wasn't echoed
diff --git a/CHANGES b/CHANGES
index 8430571..3b0f651 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+0.45 2014-10-01
+        - [bugfix] Correctly respond request in JSON results (diewald)
+
 0.44.1 2014-09-29
         - [cleanup] Prepare test suite for publication (diewald)
 
diff --git a/pom.xml b/pom.xml
index 7b8f0ab..efbf00e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
 
   <groupId>KorAP-modules</groupId>
   <artifactId>KorAP-lucene-index</artifactId>
-  <version>0.44.1</version>
+  <version>0.45</version>
   <packaging>jar</packaging>
 
   <name>KorAP-lucene-index</name>
diff --git a/src/main/java/de/ids_mannheim/korap/KorapResult.java b/src/main/java/de/ids_mannheim/korap/KorapResult.java
index b546c9c..6ec7991 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapResult.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapResult.java
@@ -146,33 +146,14 @@
 	this.warning = warning;
     };
 
-    @JsonIgnore
     public void setRequest(JsonNode request) {
         this.request = request;
-    }
-
+    };
 
     public JsonNode getRequest() {
         return this.request;
-    }
-
-    /*
-    @JsonIgnore
-    public void setBenchmarkSearchResults(long t1, long t2) {
-        this.benchmarkSearchResults =
-                (t2 - t1) < 100_000_000 ? (((double) (t2 - t1) * 1e-6) + " ms") :
-                        (((double) (t2 - t1) / 1000000000.0) + " s");
     };
 
-    public void setBenchmarkSearchResults(String bm) {
-	this.benchmarkSearchResults = bm;
-    };
-
-    public String getBenchmarkSearchResults() {
-        return this.benchmarkSearchResults;
-    }
-    */
-
     @JsonIgnore
     public void setBenchmarkHitCounter(long t1, long t2) {
         this.benchmarkHitCounter =
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index 7b2ff73..6d14e7e 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -115,7 +115,6 @@
 	};
     };
 
-
     // Maybe accept queryWrapperStuff
     public KorapSearch (SpanQueryWrapperInterface sqwi) {
 	this.query = sqwi.toQuery();
@@ -272,6 +271,7 @@
 	if (this.query == null) {
 	    KorapResult kr = new KorapResult();
 	    kr.setRequest(this.request);
+
 	    if (this.error != null)
 		kr.setError(this.error);
 	    else
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
index 9f3288d..b99596c 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
@@ -1,7 +1,7 @@
 package de.ids_mannheim.korap.search;
 
 import java.util.*;
-import java.io.IOException;
+import java.io.*;
 
 import org.apache.lucene.search.spans.SpanQuery;
 
@@ -91,4 +91,88 @@
 	assertEquals("<span class=\"context-left\">ab</span><span class=\"match\"><em class=\"class-1 level-0\">a</em></span><span class=\"context-right\"></span>", res.at("/matches/6/snippet").asText());
 
     };
+
+    @Test
+    public void checkJSONResultForJSONInput () throws IOException  {
+	KorapIndex ki = new KorapIndex();
+	FieldDocument fd = new FieldDocument();
+	fd.addString("ID", "doc-1");
+	fd.addString("UID", "1");
+	fd.addTV("tokens",
+		 "abab",
+		 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]" +
+		 "[(1-2)s:b|i:b|_1#1-2]" +
+		 "[(2-3)s:a|i:c|_2#2-3]" +
+		 "[(3-4)s:b|i:a|_3#3-4]");
+	ki.addDoc(fd);
+	fd = new FieldDocument();
+	fd.addString("ID", "doc-2");
+	fd.addString("UID", "2");
+	fd.addTV("tokens",
+		 "aba",
+		 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]" +
+		 "[(1-2)s:b|i:b|_1#1-2]" +
+		 "[(2-3)s:a|i:c|_2#2-3]");
+	ki.addDoc(fd);
+
+	// Commit!
+	ki.commit();
+
+
+	String json = getString(getClass().getResource("/queries/bsp-result-check.jsonld").getFile());
+	KorapSearch ks = new KorapSearch(json);
+	KorapResult kr = ks.run(ki);
+	assertEquals(7, kr.getTotalResults());
+
+	ObjectMapper mapper = new ObjectMapper();
+	JsonNode res = mapper.readTree(kr.toJSON());
+
+	assertEquals(7, res.at("/totalResults").asInt());
+	assertEquals("spanOr([tokens:s:a, tokens:s:b])", res.at("/query").asText());
+	assertEquals(5, res.at("/itemsPerPage").asInt());
+	assertEquals(0, res.at("/startIndex").asInt());
+	assertEquals(1, res.at("/request/meta/startPage").asInt());
+	assertEquals(5, res.at("/request/meta/count").asInt());
+	assertEquals("token", res.at("/request/meta/context/left/0").asText());
+	assertEquals(3, res.at("/request/meta/context/left/1").asInt());
+	assertEquals("char", res.at("/request/meta/context/right/0").asText());
+	assertEquals(6, res.at("/request/meta/context/right/1").asInt());
+
+	assertEquals("korap:group", res.at("/request/query/@type").asText());
+	assertEquals("operation:or", res.at("/request/query/operation").asText());
+
+	assertEquals("korap:token", res.at("/request/query/operands/0/@type").asText());
+	assertEquals("korap:term", res.at("/request/query/operands/0/wrap/@type").asText());
+	assertEquals("orth", res.at("/request/query/operands/0/wrap/layer").asText());
+	assertEquals("a", res.at("/request/query/operands/0/wrap/key").asText());
+	assertEquals("match:eq", res.at("/request/query/operands/0/wrap/match").asText());
+
+	assertEquals("korap:token", res.at("/request/query/operands/1/@type").asText());
+	assertEquals("korap:term", res.at("/request/query/operands/1/wrap/@type").asText());
+	assertEquals("orth", res.at("/request/query/operands/1/wrap/layer").asText());
+	assertEquals("b", res.at("/request/query/operands/1/wrap/key").asText());
+	assertEquals("match:eq", res.at("/request/query/operands/1/wrap/match").asText());
+
+	assertEquals(1, res.at("/matches/0/UID").asInt());
+	assertEquals("doc-1", res.at("/matches/0/docID").asText());
+	assertEquals("match-doc-1-p0-1", res.at("/matches/0/ID").asText());
+	assertEquals("<span class=\"context-left\"></span><span class=\"match\">a</span><span class=\"context-right\">bab</span>", res.at("/matches/0/snippet").asText());
+
+    };
+
+
+    public static String getString (String path) {
+	StringBuilder contentBuilder = new StringBuilder();
+	try {
+	    BufferedReader in = new BufferedReader(new FileReader(path));
+	    String str;
+	    while ((str = in.readLine()) != null) {
+		contentBuilder.append(str);
+	    };
+	    in.close();
+	} catch (IOException e) {
+	    fail(e.getMessage());
+	}
+	return contentBuilder.toString();
+    };
 };