Filtered out payloads with length 8 to be included in FocusSpans.

Change-Id: If7c09eb22dc18438b3954d431afc08ed85ed66a2
diff --git a/.gitignore b/.gitignore
index d7c1747..13c3b07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,5 +13,6 @@
 
 # /src/main/resources/
 /src/main/resources/server.properties
+/src/main/resources/krill.properties
 /src/main/resources/korap.conf
 /bin
diff --git a/Changes b/Changes
index a6f30b2..7410203 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+0.52 2015-06-10
+        - [bugfix] Fixed payload filtering in FocusSpans (margaretha)
+
 0.51 2015-03-17
         - This is a major version (prepared for the GitHub release)
         - [cleanup] Changed groupID to "de.ids_mannheim.korap",
diff --git a/pom.xml b/pom.xml
index 821b2f1..1757cd9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
 
   <groupId>de.ids_mannheim.korap</groupId>
   <artifactId>Krill</artifactId>
-  <version>0.51</version>
+  <version>0.52</version>
   <packaging>jar</packaging>
 
   <name>Krill</name>
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
index ae3fe59..9598ac0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
@@ -182,7 +182,8 @@
                 }
             }
 
-            if (removeTemporaryClasses && payload.length == 10) {
+            if (payload.length == 8
+                    || (removeTemporaryClasses && payload.length == 10)) {
                 continue;
             }
             candidateSpan.getPayloads().add(payload.clone());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
index a183fe8..63d2a64 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -16,7 +16,6 @@
 import de.ids_mannheim.korap.query.SpanFocusQuery;
 import de.ids_mannheim.korap.query.SpanRelationMatchQuery;
 import de.ids_mannheim.korap.query.SpanRelationQuery;
-import de.ids_mannheim.korap.query.SpanSegmentQuery;
 import de.ids_mannheim.korap.query.SpanTermWithIdQuery;
 import de.ids_mannheim.korap.query.SpanWithAttributeQuery;
 import de.ids_mannheim.korap.response.Result;
@@ -346,6 +345,10 @@
         SpanFocusQuery rv = new SpanFocusQuery(rm, (byte) 1);
         rv.setSorted(false);
 
+        assertEquals(
+                "focus(1: focus(#[1,2]spanSegment(spanRelation(base:>:child-of), {1: <base:np />})))",
+                rv.toString());
+
         kr = ki.search(rv, (short) 10);
 
         assertEquals(4, kr.getTotalResults());
@@ -428,15 +431,14 @@
     }
 
     /**
-     * Relation with specific targets, return any sources
+     * Relation with specific sources, return any targets
      * */
     @Test
     public void testCase7 () throws IOException {
         ki.addDoc(createFieldDoc2());
         ki.commit();
 
-        // return all children that are NP
-
+        // match all children that are NP
         SpanElementQuery seq1 = new SpanElementQuery("base", "np");
         SpanClassQuery scq1 = new SpanClassQuery(seq1, (byte) 1);
 
@@ -445,12 +447,16 @@
         srq.setTargetClass((byte) 2);
 
         SpanRelationMatchQuery rm = new SpanRelationMatchQuery(srq, scq1, true);
-        SpanQuery rv = new SpanFocusQuery(rm, (byte) 1);
-
+        // SpanQuery rv = new SpanFocusQuery(rm, (byte) 1);
 
         //return all parents of np
-        SpanFocusQuery rv2 = new SpanFocusQuery(rv, (byte) 2);
+        SpanFocusQuery rv2 = new SpanFocusQuery(rm, (byte) 2);
         rv2.setSorted(false);
+
+        assertEquals(
+                "focus(2: focus(#[1,2]spanSegment({2: target:spanRelation(base:>:child-of)}, {1: <base:np />})))",
+                rv2.toString());
+
         kr = ki.search(rv2, (short) 10);
 
         assertEquals((long) 4, kr.getTotalResults());
@@ -537,9 +543,12 @@
         srq.setSourceClass((byte) 2);
         SpanRelationMatchQuery rm = new SpanRelationMatchQuery(srq, scq1, true);
         SpanFocusQuery rv = new SpanFocusQuery(rm, (byte) 2);
-
         rv.setSorted(false);
 
+        assertEquals(
+                "focus(2: focus(#[1,2]spanSegment({2: source:spanRelation(base:<:child-of)}, {1: <base:np />})))",
+                rv.toString());
+
         kr = ki.search(rv, (short) 10);
 
         assertEquals((long) 7, kr.getTotalResults());
@@ -569,6 +578,10 @@
         rm = new SpanRelationMatchQuery(srq, scq2, scq1, true);
         rv = new SpanFocusQuery(rm, (byte) 2);
 
+        assertEquals(
+                "focus(2: focus(#[1,2]spanSegment(focus(#2: spanSegment(spanRelation(base:>:child-of), {2: spanTermWithId(base:pos:ART)})), {1: <base:np />})))",
+                rv.toString());
+
         kr = ki.search(rv, (short) 10);
 
         assertEquals((long) 2, kr.getTotalResults());
@@ -578,10 +591,11 @@
         assertEquals(6, kr.getMatch(1).getEndPos());
 
         // return all nps whose children are articles
-        SpanSegmentQuery rv3 = new SpanSegmentQuery(rv,
-                new SpanTermWithIdQuery(new Term("base", "pos:ART"), true));
-        
-        SpanFocusQuery sf = new SpanFocusQuery(rv3, (byte) 1);
+        SpanFocusQuery sf = new SpanFocusQuery(rm, (byte) 1);
+        assertEquals(
+                "focus(1: focus(#[1,2]spanSegment(focus(#2: spanSegment(spanRelation(base:>:child-of), {2: spanTermWithId(base:pos:ART)})), {1: <base:np />})))",
+                sf.toString());
+
         kr = ki.search(sf, (short) 10);
 
         assertEquals((long) 2, kr.getTotalResults());