Fixed test on wildcard expansion

Change-Id: Ied1ca884c5f71720506e996bb0e5eabf8e5daaf0
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index b58ef0c..7c52a10 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -1334,15 +1334,14 @@
             // Rewrite query (for regex and wildcard queries)
             // Revise!
             // Based on core/src/java/org/apache/lucene/search/IndexSearcher.java
-            // and highlighter/src/java/org/apache/lucene/search/postingshighlight/PostingsHighlighter.java
-            for (Query rewrittenQuery = query
-                    .rewrite(this.reader()); !rewrittenQuery
-                            .equals(query); rewrittenQuery = query
-                                    .rewrite(this.reader())) {
+            // and highlighter/src/java/org/apache/lucene/search/
+			//   postingshighlight/PostingsHighlighter.java
+            for (Query rewrittenQuery = query.rewrite(this.reader());
+				 !rewrittenQuery.equals(query);
+				 rewrittenQuery = query.rewrite(this.reader())) {
                 query = (SpanQuery) rewrittenQuery;
             };
 
-
             // Todo: run this in a separated thread
             for (LeafReaderContext atomic : this.reader().leaves()) {
 
@@ -1507,6 +1506,7 @@
 
             kr.setTotalResults(cutoff ? (long) -1 : (long) i);
         }
+
         catch (IOException e) {
             kr.addError(600, "Unable to read index", e.getLocalizedMessage());
             log.warn(e.getLocalizedMessage());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
index 882bbfd..c731021 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
@@ -144,30 +144,29 @@
     }
 
 
-//  assertEquals(sqwi.toQuery().toString(),"spanMultipleDistance({129: SpanMultiTermQueryWrapper(tokens:s:meine*)}, "+
-  //                 "{129: tokens:l:Erfahrung}, "+
-  //                 "[(w[1:2], ordered, notExcluded), "+
-  //                 "(base/s:s[0:0], ordered, notExcluded)])");
+    //  assertEquals(sqwi.toQuery().toString(),"spanMultipleDistance({129: SpanMultiTermQueryWrapper(tokens:s:meine*)}, "+
+	//                 "{129: tokens:l:Erfahrung}, "+
+	//                 "[(w[1:2], ordered, notExcluded), "+
+	//                 "(base/s:s[0:0], ordered, notExcluded)])");
 
-  @Test
-  public void testQueryWithWildCard () throws IOException {
-      // meine* /+w1:2,s0 &Erfahrung
-      ki = new KrillIndex();
-      ki.addDoc(createFieldDoc5());
-      ki.commit();
+	@Test
+	public void testQueryWithWildCard () throws IOException {
+		// meine* /+w1:2,s0 &Erfahrung
+		ki = new KrillIndex();
+		ki.addDoc(createFieldDoc5());
+		ki.commit();
       
-      WildcardQuery wcquery = new WildcardQuery(new Term("base", "meine*"));
-      SpanMultiTermQueryWrapper<WildcardQuery> mtq =
+		WildcardQuery wcquery = new WildcardQuery(new Term("base", "s:Meine*"));
+		SpanMultiTermQueryWrapper<WildcardQuery> mtq =
             new SpanMultiTermQueryWrapper<WildcardQuery>(wcquery);
+
+		assertEquals(wcquery.toString(), "base:s:Meine*");
       
-      kr = ki.search(mtq, (short) 10);
-//      for (Match m: kr.getMatches()){
-//          System.out.println(m.getStartPos() + ", "+ m.getEndPos());
-//      }
-      assertEquals(3, kr.getMatches().size());
-      assertEquals(0, kr.getMatch(0).getStartPos());
-      assertEquals(1, kr.getMatch(0).getEndPos());
-  }
+		kr = ki.search(mtq, (short) 10);
+		assertEquals(4, kr.getMatches().size());
+		assertEquals(0, kr.getMatch(0).getStartPos());
+		assertEquals(1, kr.getMatch(0).getEndPos());
+	}
     
     @Test
     public void testUnorderedTokenDistance () throws IOException {