Upgraded RelationPart to have relation right side positions as properties
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRelationPartQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRelationPartQuery.java
index c5a58c4..bcdfca8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRelationPartQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRelationPartQuery.java
@@ -17,28 +17,32 @@
  * 
  * 	@author margaretha
  * */
-public class SpanRelationPartQuery extends SpanWithIdQuery{
+public class SpanRelationPartQuery extends SpanRelationQuery{
 	
 	private static String elementStr = "s"; // default element interval type
 	
 	private SpanElementQuery elementQuery;
 	private boolean matchRight;  // if false, match left
-	private int window;
+	private boolean inverseRelation;  // if false, sort result by the left
+	private int window;	
 	
 	public SpanRelationPartQuery(SpanRelationQuery spanRelationQuery,
 			SpanWithIdQuery secondClause, // match tokenWithIdQuery, ElementQuery, RelationQuery
 			boolean matchRight,
+			boolean returnRight,
 			boolean collectPayloads) {
-		this(spanRelationQuery, secondClause, elementStr, matchRight, collectPayloads);		
+		this(spanRelationQuery, secondClause, elementStr, matchRight, returnRight, collectPayloads);		
 	}
 	
 	public SpanRelationPartQuery(SpanRelationQuery spanRelationQuery,
 			SpanWithIdQuery secondClause, 
 			String elementStr,
 			boolean matchRight,
+			boolean inverseRelation,
 			boolean collectPayloads) {
 		super(spanRelationQuery, secondClause, collectPayloads);
 		this.matchRight = matchRight;
+		this.inverseRelation = inverseRelation;
 		elementQuery = new SpanElementQuery(spanRelationQuery.getField(), elementStr);		
 	}
 	
@@ -46,9 +50,11 @@
 			SpanWithIdQuery secondClause, // match tokenWithIdQuery, ElementQuery, RelationQuery
 			int window,
 			boolean matchRight,
+			boolean inverseRelation,
 			boolean collectPayloads) {
 		super(spanRelationQuery, secondClause, collectPayloads);
 		this.matchRight = matchRight;
+		this.inverseRelation = inverseRelation;
 		this.window = window;
 	}
 	
@@ -65,6 +71,7 @@
 				(SpanWithIdQuery) this.secondClause,
 				this.elementQuery.getElementStr(),
 				this.matchRight, 
+				this.inverseRelation,
 				this.collectPayloads
 		);		
 		return sq;
@@ -101,6 +108,14 @@
 		this.matchRight = matchRight;
 	}
 
+	public boolean isInverseRelation() {
+		return inverseRelation;
+	}
+
+	public void setInverseRelation(boolean inverseRelation) {
+		this.inverseRelation = inverseRelation;
+	}
+
 	public SpanElementQuery getElementQuery() {
 		return elementQuery;
 	}
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
index e5c0613..2c03fdc 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
@@ -15,60 +15,56 @@
 import de.ids_mannheim.korap.query.spans.SpansWithAttribute;
 import de.ids_mannheim.korap.query.spans.ElementSpans;
 import de.ids_mannheim.korap.query.spans.RelationSpans;
+import de.ids_mannheim.korap.query.spans.TermSpansWithId;
 
-/**	Enumeration of spans (e.g. element or relation spans) having some specific attribute(s) or 
- * 	<em>not</em> having some attribute(s).
+/**	Enumeration of spans (e.g. element or relation spans) having some 
+ * 	specific attribute(s) or <em>not</em> having some attribute(s).
  * 
  * 	@author margaretha
  */
-public class SpanWithAttributeQuery extends SimpleSpanQuery{
+public class SpanWithAttributeQuery extends SpanWithIdQuery{
 		
 	private boolean isMultipleAttributes;
 	private String type;
 	
-	public SpanWithAttributeQuery(SpanElementQuery firstClause,
+	public SpanWithAttributeQuery(SpanWithIdQuery firstClause,
 			SpanAttributeQuery secondClause, boolean collectPayloads) {
 		super(firstClause, secondClause, collectPayloads);
-		type = "spanElementWithAttribute"; 
+		setType();
 	}
 	
-	public SpanWithAttributeQuery(SpanElementQuery firstClause,
+	public SpanWithAttributeQuery(SpanWithIdQuery firstClause,
 			List<SpanQuery> secondClauses, boolean collectPayloads) {
 		super(firstClause, secondClauses, collectPayloads);
 		isMultipleAttributes = true;
-		type = "spanElementWithAttribute";
-	}
+		setType();
+	}	
 	
-	public SpanWithAttributeQuery(SpanRelationQuery firstClause,
-			SpanAttributeQuery secondClause, boolean collectPayloads) {
-		super(firstClause, secondClause, collectPayloads);
-		type = "spanRelationWithAttribute";		
+	public String getType() {
+		return type;
 	}
-	
-	public SpanWithAttributeQuery(SpanRelationQuery firstClause,
-			List<SpanQuery> secondClauses, boolean collectPayloads) {
-		super(firstClause, secondClauses, collectPayloads);
-		isMultipleAttributes = true;
-		type = "spanRelationWithAttribute";		
+
+	public void setType() {
+		if (SpanElementQuery.class.isInstance(firstClause)){
+			type = "spanElementWithAttribute"; 
+		}
+		else if (SpanRelationQuery.class.isInstance(firstClause)){
+			type = "spanRelationWithAttribute";	
+		}
+		else if (SpanTermWithIdQuery.class.isInstance(firstClause)){
+			type = "spanTermWithAttribute";	
+		}
 	}
 
 	@Override
 	public SimpleSpanQuery clone() {
 		SpanWithAttributeQuery sq;
 		if (!isMultipleAttributes){			
-			if (type.equals("spanElementWithAttribute")){			
-				sq = new SpanWithAttributeQuery( 
-						(SpanElementQuery) firstClause.clone(), 
-						(SpanAttributeQuery) secondClause.clone(), 
-						collectPayloads);
-			}
-			else {
-				sq = new SpanWithAttributeQuery( 
-						(SpanRelationQuery) firstClause.clone(), 
-						(SpanAttributeQuery) secondClause.clone(), 
-						collectPayloads);
-			}
-		}
+			sq = new SpanWithAttributeQuery( 
+					(SpanWithIdQuery) firstClause.clone(), 
+					(SpanAttributeQuery) secondClause.clone(), 
+					collectPayloads);
+		}		
 		else {
 			List<SpanQuery> clauseList = new ArrayList<SpanQuery>();
 			SpanAttributeQuery saq;
@@ -76,19 +72,10 @@
 				saq = (SpanAttributeQuery) q;
 				clauseList.add(saq.clone());
 			}
-			
-			if (type.equals("spanElementWithAttribute")){			
-				sq = new SpanWithAttributeQuery( 
-						(SpanElementQuery) firstClause.clone(), 
-						clauseList, 
-						collectPayloads);
-			}
-			else {
-				sq = new SpanWithAttributeQuery( 
-						(SpanRelationQuery) firstClause.clone(), 
-						clauseList, 
-						collectPayloads);
-			}
+			sq = new SpanWithAttributeQuery( 
+					(SpanWithIdQuery) firstClause.clone(), 
+					clauseList, 
+					collectPayloads);
 		}
 		return sq;
 	}
@@ -103,8 +90,12 @@
 			return new SpansWithAttribute(this, (ElementSpans) spans, 
 					context, acceptDocs, termContexts);
 		}
+		else if (type.equals("spanRelationWithAttribute")){
+			return new SpansWithAttribute(this, (RelationSpans) spans,
+					context, acceptDocs, termContexts);
+		}
 		
-		return new SpansWithAttribute(this, (RelationSpans) spans,
+		return new SpansWithAttribute(this, (TermSpansWithId) spans,
 				context, acceptDocs, termContexts);
 	}
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java
index d117f98..aefd7ce 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java
@@ -1,5 +1,7 @@
 package de.ids_mannheim.korap.query;
 
+import java.util.List;
+
 import org.apache.lucene.search.spans.SpanQuery;
 
 public abstract class SpanWithIdQuery extends SimpleSpanQuery{
@@ -12,4 +14,9 @@
 			boolean collectPayloads) {
 		super(firstClause, secondClause, collectPayloads);
 	}
+	
+	public SpanWithIdQuery(SpanQuery firstClause,
+			List<SpanQuery> secondClauses, boolean collectPayloads) {
+		super(firstClause, secondClauses, collectPayloads);
+	}
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
index b4c5dba..43163c8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
@@ -3,6 +3,7 @@
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -27,14 +28,10 @@
 
 	private List<CandidateElementSpans> candidateList;
 	private int currentDoc, currentPosition;
-	//private short elementRef;
 	private TermSpans termSpans;	
 	
-	protected Logger logger = LoggerFactory.getLogger(ElementSpans.class);
+	private Logger logger = LoggerFactory.getLogger(ElementSpans.class);
 
-        // This advices the java compiler to ignore all loggings
-        public static final boolean DEBUG = false;
-	
 	public ElementSpans(SpanElementQuery spanElementQuery,
 			AtomicReaderContext context, Bits acceptDocs,
 			Map<Term, TermContext> termContexts) throws IOException {
@@ -71,8 +68,7 @@
 				return true;
 			}
 			else{
-			        if (DEBUG)
-				     logger.info("Setting candidate list");
+			    //logger.info("Setting candidate list");
 				setCandidateList();				
 				currentDoc = termSpans.doc();
 				currentPosition = termSpans.start();
@@ -126,8 +122,8 @@
 				cs.setSpanId((short) -1);
 			}
 			// Copy the start and end character offsets
-			byte[] b = new byte[8];
-			System.arraycopy(bb.array(), 0, b, 0, 8);
+			byte[] b = new byte[8];			
+			b = Arrays.copyOfRange(bb.array(), 0, 8);
 			cs.setPayloads(Collections.singletonList(b));
 	    }
 	    else {	
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RelationBaseSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RelationBaseSpans.java
new file mode 100644
index 0000000..528aec1
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RelationBaseSpans.java
@@ -0,0 +1,56 @@
+package de.ids_mannheim.korap.query.spans;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermContext;
+import org.apache.lucene.util.Bits;
+
+import de.ids_mannheim.korap.query.SpanWithIdQuery;
+
+public abstract class RelationBaseSpans extends SpansWithId{
+
+	protected short leftId, rightId;
+	protected int rightStart, rightEnd;
+	
+	public RelationBaseSpans(SpanWithIdQuery spanWithIdQuery,
+			AtomicReaderContext context, Bits acceptDocs,
+			Map<Term, TermContext> termContexts) throws IOException {
+		super(spanWithIdQuery, context, acceptDocs, termContexts);
+		// TODO Auto-generated constructor stub
+	}
+	
+	public short getLeftId() {
+		return leftId;
+	}
+
+	public void setLeftId(short leftId) {
+		this.leftId = leftId;
+	}
+
+	public short getRightId() {
+		return rightId;
+	}
+
+	public void setRightId(short rightId) {
+		this.rightId = rightId;
+	}
+
+	public int getRightStart() {
+		return rightStart;
+	}
+
+	public void setRightStart(int rightStart) {
+		this.rightStart = rightStart;
+	}
+
+	public int getRightEnd() {
+		return rightEnd;
+	}
+
+	public void setRightEnd(int rightEnd) {
+		this.rightEnd = rightEnd;
+	}
+}
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RelationPartSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RelationPartSpans.java
index 228c0ef..d3889f7 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/RelationPartSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RelationPartSpans.java
@@ -23,17 +23,18 @@
  * 
  * 	@author margaretha
  * */
-public class RelationPartSpans extends SpansWithId{
+public class RelationPartSpans extends RelationBaseSpans{
 	
-	private RelationSpans relationSpans;
+	private RelationBaseSpans relationSpans;
 	private SpansWithId matcheeSpans;
 	private ElementSpans element;
 	private List<CandidateRelationSpan> candidateRelations;
 	
 	private boolean matchRight;
+	private boolean inverse;
 	private boolean hasMoreMatchees;
 	
-	private short leftId, rightId;
+//	private short leftId, rightId;
 	private int window;
 	
 	public RelationPartSpans(SpanRelationPartQuery query,	
@@ -47,7 +48,7 @@
 		else{
 			window = query.getWindow();
 		}
-		relationSpans = (RelationSpans) firstSpans;
+		relationSpans = (RelationBaseSpans) firstSpans;
 		matcheeSpans = (SpansWithId) secondSpans;		
 		// hack
 		matcheeSpans.hasSpanId = true;
@@ -59,6 +60,7 @@
   		}
 		candidateRelations = new ArrayList<CandidateRelationSpan>();
 		matchRight = query.isMatchRight();
+		inverse = query.isInverseRelation();
 	}
 
 	@Override
@@ -73,13 +75,17 @@
 			if (candidateRelations.size() > 0){
 				CandidateRelationSpan relationSpan = candidateRelations.get(0);				
 				matchDocNumber = relationSpan.getDoc();
-				if (matchRight){
+				if (!inverse){
 					matchStartPosition = relationSpan.getStart();
 					matchEndPosition = relationSpan.getEnd();
+					setRightStart(relationSpan.getRightStart());
+					setRightEnd(relationSpan.getRightEnd());
 				}					
-				else{
+				else{ // maybe a bit confusing -- inverse relation
 					matchStartPosition = relationSpan.getRightStart();
 					matchEndPosition = relationSpan.getRightEnd();
+					setRightStart(relationSpan.getStart());
+					setRightEnd(relationSpan.getEnd());
 				}
 				setLeftId(relationSpans.getLeftId());
 				setRightId(relationSpan.getRightId());
@@ -177,11 +183,11 @@
 	private int matchRelation(int i, CandidateRelationSpan r, int startPos, int endPos) throws IOException {
 		if(startPos == matcheeSpans.start() ){
 			if 	(endPos == matcheeSpans.end()){		
-				if (matchRight && r.getRightId() == matcheeSpans.getSpanId()){
+				if (!inverse && r.getRightId() == matcheeSpans.getSpanId()){
 					r.sortRight = false;
 					candidateRelations.add(r);
 				}
-				else if (!matchRight && r.getLeftId() == matcheeSpans.getSpanId()) {
+				else if (inverse && r.getLeftId() == matcheeSpans.getSpanId()) {
 					r.sortRight = true;
 					candidateRelations.add(r);
 				}
@@ -219,7 +225,7 @@
 		return 0;
 	}
 	
-	public short getLeftId() {
+	/*public short getLeftId() {
 		return leftId;
 	}
 
@@ -233,7 +239,7 @@
 
 	public void setRightId(short rightId) {
 		this.rightId = rightId;
-	}
+	}*/
 
 	class CandidateRelationSpan extends CandidateSpans implements Comparable<CandidateSpans>{
 		
@@ -241,7 +247,7 @@
 		private short leftId, rightId;
 		private boolean sortRight;
 		
-		public CandidateRelationSpan(RelationSpans span, boolean sortRight) 
+		public CandidateRelationSpan(RelationBaseSpans span, boolean sortRight) 
 				throws IOException {
 			super(span);
 			this.rightStart = span.getRightStart();
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
index 487f841..380e899 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
@@ -39,12 +39,12 @@
  * 
  * 	@author margaretha
  * */
-public class RelationSpans extends SpansWithId{
+public class RelationSpans extends RelationBaseSpans{
 
 	//short relationId;
-	private int rightStart, rightEnd;
+//	private int rightStart, rightEnd;
 	private int currentDoc, currentPosition;
-	private short leftId, rightId;
+//	private short leftId, rightId;
 	
 	private TermSpans relationTermSpan;
 	
@@ -181,27 +181,21 @@
 		this.rightEnd = rightEnd;
 	}
 
-
-
-	public short getLeftId() {
-		return leftId;
-	}
-
-	public void setLeftId(short leftId) {
-		this.leftId = leftId;
-	}
-
-
-
-	public short getRightId() {
-		return rightId;
-	}
-
-	public void setRightId(short rightId) {
-		this.rightId = rightId;
-	}
-
-
+//	public short getLeftId() {
+//		return leftId;
+//	}
+//
+//	public void setLeftId(short leftId) {
+//		this.leftId = leftId;
+//	}
+//
+//	public short getRightId() {
+//		return rightId;
+//	}
+//
+//	public void setRightId(short rightId) {
+//		this.rightId = rightId;
+//	}
 
 	class CandidateRelationSpan extends CandidateSpans implements Comparable<CandidateSpans>{
 		
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java
index 40b8d40..344d974 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java
@@ -25,7 +25,7 @@
  *
  * 	@author margaretha
  * */
-public class SpansWithAttribute extends SimpleSpans{
+public class SpansWithAttribute extends SpansWithId{
 	
 	private SpansWithId withAttributeSpans;
 	private List<AttributeSpans> attributeList;
@@ -83,15 +83,16 @@
 	 * */
 	private boolean advance() throws IOException {
 		
-		while (hasMoreSpans && computeElementPosition()){			
+		while (hasMoreSpans && searchSpanPosition()){			
 		 	    //logger.info("element: " + withAttributeSpans.start() + ","+ withAttributeSpans.end() +
 				//	" ref:"+withAttributeSpans.getSpanId());
 			
-			if (checkElementRef() && checkNotElementRef()){			
+			if (checkSpanId() && checkNotSpanId()){			
 				this.matchDocNumber = withAttributeSpans.doc();
 				this.matchStartPosition = withAttributeSpans.start();
 				this.matchEndPosition = withAttributeSpans.end();
 				this.matchPayload = withAttributeSpans.getPayload();
+				this.spanId = withAttributeSpans.getSpanId();
 				
 				if (attributeList.size() > 0)
 					hasMoreSpans = attributeList.get(0).next();
@@ -108,7 +109,7 @@
 	/** Ensuring all the attribute spans having the same elementRef with 
 	 * 	the actual element's elementRef.
 	 * */
-	private boolean checkElementRef() throws IOException{
+	private boolean checkSpanId() throws IOException{
 		
 		for (AttributeSpans attribute: attributeList){			
 			if (withAttributeSpans.getSpanId() != attribute.getSpanId()){
@@ -128,7 +129,7 @@
 	/** Ensuring elements do not contain the not attributes. In other words, 
 	 * 	the elementRef is not the same as the not attribute's elementRefs. 
 	 * */
-	private boolean checkNotElementRef() throws IOException{
+	private boolean checkNotSpanId() throws IOException{
 		for (AttributeSpans notAttribute: notAttributeList){
 			if (!notAttribute.isFinish() && 
 					withAttributeSpans.start() == notAttribute.start() &&
@@ -144,7 +145,7 @@
 	/**	Search for a possible element having the same doc and start position as
 	 * 	the attributes.
 	 * */
-	private boolean computeElementPosition() throws IOException {		
+	private boolean searchSpanPosition() throws IOException {		
 
 		while (hasMoreSpans){
 			
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java
index b851e04..f1d836a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java
@@ -31,6 +31,4 @@
 	public void setSpanId(short spanId) {
 		this.spanId = spanId;
 	}
-		
-	
 }
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 a693858..ace4662 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -350,13 +350,10 @@
 						new SpanTermQuery(new Term("base",">:child-of")),true
 				), 
 				new SpanElementQuery("base","np"), 
-				true, true); 
+				true, false, true); 
 				
 		kr = ki.search(rv,(short) 10);
-		/*for (KorapMatch km : kr.getMatches()){		
-		System.out.println(km.getStartPos() +","+km.getEndPos()+" "
-			+km.getSnippetBrackets());
-		}	*/
+		
 		assertEquals(7, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos());
 		assertEquals(1,kr.getMatch(0).getEndPos());
@@ -384,6 +381,23 @@
 		assertEquals(5,kr.getMatch(1).getStartPos());
 		assertEquals(6,kr.getMatch(1).getEndPos());
 		
+		// return all nps whose children are articles
+		SpanRelationPartQuery rv3 = 
+			new SpanRelationPartQuery(rv, 
+				new SpanTermWithIdQuery(new Term("base","pos:ART"), true), 
+				false, true, true); 
+		kr = ki.search(rv3,(short) 10);
+		
+		/*for (KorapMatch km : kr.getMatches()){		
+			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+				+km.getSnippetBrackets()
+					);
+		}	*/
+		assertEquals(2, kr.getTotalResults());
+		assertEquals(2,kr.getMatch(0).getStartPos());
+		assertEquals(4,kr.getMatch(0).getEndPos());
+		assertEquals(5,kr.getMatch(1).getStartPos());
+		assertEquals(7,kr.getMatch(1).getEndPos());
 	}
 	
 	/** Using the opposite relation
@@ -403,7 +417,7 @@
 		SpanRelationPartQuery rv =new SpanRelationPartQuery(
 				spanRelationQuery, 
 				new SpanElementQuery("base","np"), 
-				false, true);
+				false, true, true);
 		kr = ki.search(rv,(short) 10);
 		
 		/*for (KorapMatch km : kr.getMatches()){
@@ -444,7 +458,7 @@
 		SpanRelationPartQuery rv =new SpanRelationPartQuery(
 				spanRelationQuery, 
 				new SpanElementQuery("base","np"), 
-				true, true);
+				true, false, true);
 		kr = ki.search(rv,(short) 10);
 		
 		/*for (KorapMatch km : kr.getMatches()){
@@ -477,7 +491,7 @@
 						new SpanTermQuery(new Term("base",">:child-of")),true
 				), 
 				new SpanElementQuery("base","np"), 
-				false, true);
+				false, true, true);
 		kr = ki.search(rv,(short) 10);
 		/*for (KorapMatch km : kr.getMatches()){
 			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
@@ -499,7 +513,7 @@
 				new SpanRelationQuery(
 						new SpanTermQuery(new Term("base",">:child-of")),true
 				),
-				rv, true, true);
+				rv, true, false, true);
 				
 		kr = ki.search(rv3,(short) 10);
 		
@@ -526,7 +540,7 @@
 						new SpanTermQuery(new Term("base",">:dep")),true
 				), 
 				new SpanTermWithIdQuery(new Term("base","pos:NN"), true), 
-				true, true);
+				true, false, true);
 		kr = ki.search(rv,(short) 10);
 		assertEquals(3, kr.getTotalResults());
 		assertEquals(1,kr.getMatch(0).getStartPos());
@@ -542,7 +556,7 @@
 						new SpanTermQuery(new Term("base","<:dep")),true
 				), 
 				new SpanTermWithIdQuery(new Term("base","pos:NN"),true), 
-				true, true);
+				true, false, true);
 		kr = ki.search(rv,(short) 10);
 		assertEquals(3, kr.getTotalResults());
 		assertEquals(2,kr.getMatch(0).getStartPos());
@@ -560,7 +574,7 @@
 						new SpanTermQuery(new Term("base",">:dep")),true
 				), 
 				new SpanTermWithIdQuery(new Term("base","pos:NN"),true), 
-				false, true);
+				false, true, true);
 		kr = ki.search(rv,(short) 10);
 			
 		assertEquals(3, kr.getTotalResults());
@@ -577,7 +591,7 @@
 						new SpanTermQuery(new Term("base","<:dep")),true
 				), 
 				new SpanTermWithIdQuery(new Term("base","pos:NN"),true), 
-				false, true);
+				false, true, true);
 		kr = ki.search(rv,(short) 10);
 		
 		/*for (KorapMatch km : kr.getMatches()){		
@@ -606,7 +620,7 @@
 						new SpanTermQuery(new Term("base",">:child-of")),true
 				), 
 				new SpanElementQuery("base","np"), 
-				6, true, true); 
+				6, true, false, true); 
 				
 		kr = ki.search(rv,(short) 10);
 		assertEquals(7, kr.getTotalResults());
@@ -616,7 +630,7 @@
 						new SpanTermQuery(new Term("base","<:dep")),true
 				), 
 				new SpanTermWithIdQuery(new Term("base","pos:NN"),true), 
-				3, false, true);
+				3, false, true, true);
 		kr = ki.search(rv,(short) 10);
 		assertEquals(3, kr.getTotalResults());