Switch segment wrapper to new segment implementation
diff --git a/pom.xml b/pom.xml
index 0d5adaf..db5bf67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,12 +1,14 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
+
+<!--
   <parent>
     <groupId>KorAP-modules</groupId>
     <artifactId>KorAP-core-modules</artifactId>
     <version>LATEST</version>
   </parent>
-
+-->
   <groupId>KorAP-modules</groupId>
   <artifactId>KorAP-lucene-index</artifactId>
   <version>0.26.1</version>
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
index 66db669..c6ba009 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
@@ -6,10 +6,10 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
-import org.apache.lucene.search.spans.SpanNearQuery;
 import org.apache.lucene.search.spans.SpanNotQuery;
 import org.apache.lucene.search.spans.SpanOrQuery;
 import de.ids_mannheim.korap.query.wrap.SpanRegexQueryWrapper;
+import de.ids_mannheim.korap.query.SpanSegmentQuery;
 
 /**
  * @author Nils Diewald
@@ -125,6 +125,8 @@
 	}
 
 	else if (this.inclusive.size() == 0 && this.exclusive.size() >= 1) {
+
+	    // Not supported anymore
 	    return (SpanQuery) new SpanNotQuery(
 		new SpanTermQuery(new Term(this.field, "T")),
 	        this._listToOrQuery(this.exclusive)
@@ -143,15 +145,7 @@
 	SpanQuery query = list.get(0);
 
 	for (int i = 1; i < list.size(); i++) {
-	    query = new SpanNearQuery(
-	        new SpanQuery[] {
-	            query,
-	            list.get(i)
-	        },
-	        -1,
-	        false,
-		false
-            );
+	    query = new SpanSegmentQuery(query, list.get(i));
 	};
 
 	return (SpanQuery) query;
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
index d1dc5b3..6442f29 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
@@ -15,45 +15,45 @@
     @Test
     public void korapQuerySegment () {
 	SpanQuery sq = new KorapQuery("field1").seg("a").with("b").toQuery();
-	assertEquals("spanNear([field1:a, field1:b], -1, false)", sq.toString());
+	assertEquals("spanSegment(field1:a, field1:b)", sq.toString());
 
 	sq = new KorapQuery("field2").seg("a", "b").with("c").toQuery();
-	assertEquals("spanNear([spanNear([field2:a, field2:b], -1, false), field2:c], -1, false)", sq.toString());
+	assertEquals("spanSegment(spanSegment(field2:a, field2:b), field2:c)", sq.toString());
     };
 
     @Test
     public void korapQueryRegexSegment () {
 	KorapQuery kq = new KorapQuery("field1");
 	SpanQuery sq = kq.seg("a").with(kq.re("b.*c")).toQuery();
-	assertEquals("spanNear([field1:a, SpanMultiTermQueryWrapper(field1:/b.*c/)], -1, false)", sq.toString());
+	assertEquals("spanSegment(field1:a, SpanMultiTermQueryWrapper(field1:/b.*c/))", sq.toString());
 
 	kq = new KorapQuery("field2");
 	sq = kq.seg(kq.re("a.*")).with("b").toQuery();
-	assertEquals("spanNear([SpanMultiTermQueryWrapper(field2:/a.*/), field2:b], -1, false)", sq.toString());
+	assertEquals("spanSegment(SpanMultiTermQueryWrapper(field2:/a.*/), field2:b)", sq.toString());
     };
 
     @Test
     public void korapQueryRegexSegment2 () {
 	KorapQuery kq = new KorapQuery("field");
 	SpanQuery sq = kq.seg("a").with(kq.or("b").or("c")).toQuery();
-	assertEquals("spanNear([field:a, spanOr([field:b, field:c])], -1, false)", sq.toString());
+	assertEquals("spanSegment(field:a, spanOr([field:b, field:c]))", sq.toString());
 
 	kq = new KorapQuery("field");
 	sq = kq.seg("a").with(kq.or("b", "c")).toQuery();
-	assertEquals("spanNear([field:a, spanOr([field:b, field:c])], -1, false)", sq.toString());
+	assertEquals("spanSegment(field:a, spanOr([field:b, field:c]))", sq.toString());
 
 
 	kq = new KorapQuery("field");
 	// [ a & (b | /c.*d/) ]
 	sq = kq.seg("a").with(kq.or("b").or(kq.re("c.*d"))).toQuery();
-	assertEquals("spanNear([field:a, spanOr([field:b, SpanMultiTermQueryWrapper(field:/c.*d/)])], -1, false)", sq.toString());
+	assertEquals("spanSegment(field:a, spanOr([field:b, SpanMultiTermQueryWrapper(field:/c.*d/)]))", sq.toString());
     };
 
     @Test
     public void korapQuerySequenceSegment () {
 	KorapQuery kq = new KorapQuery("field");
 	SpanQuery sq = kq.seq(kq.seg("a").with(kq.or("b", "c"))).append("d").append(kq.re("e.?f")).toQuery();
-	assertEquals("spanNext(spanNext(spanNear([field:a, spanOr([field:b, field:c])], -1, false), field:d), SpanMultiTermQueryWrapper(field:/e.?f/))", sq.toString());
+	assertEquals("spanNext(spanNext(spanSegment(field:a, spanOr([field:b, field:c])), field:d), SpanMultiTermQueryWrapper(field:/e.?f/))", sq.toString());
     };
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
index f8196a0..354797b 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -97,7 +97,7 @@
 	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp9.json").getFile());
 
 	// [base=Katze&orth=Katzen]
-	assertEquals(sqwi.toQuery().toString(), "spanNear([tokens:"+defaultFoundry+"l:Katze, tokens:s:Katzen], -1, false)");
+	assertEquals(sqwi.toQuery().toString(), "spanSegment(tokens:"+defaultFoundry+"l:Katze, tokens:s:Katzen)");
     };
 
     @Test
@@ -161,7 +161,7 @@
 	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp16.json").getFile());
 
 	// [(base=bar|base=foo)&orth=foobar]
-	assertEquals(sqwi.toQuery().toString(), "spanNear([spanOr([tokens:"+defaultFoundry+"l:bar, tokens:"+defaultFoundry+"l:foo]), tokens:s:foobar], -1, false)");
+	assertEquals(sqwi.toQuery().toString(), "spanSegment(spanOr([tokens:"+defaultFoundry+"l:bar, tokens:"+defaultFoundry+"l:foo]), tokens:s:foobar)");
     };
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java
index 28ef2b4..e7b44d1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java
@@ -40,7 +40,7 @@
 	SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field", "a", "b", "c");
 	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
 	ssaquery.or("d").or(segquery).or("e");
-	assertEquals("spanOr([field:d, spanNear([spanNear([field:a, field:b], -1, false), field:c], -1, false), field:e])", ssaquery.toQuery().toString());
+	assertEquals("spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])", ssaquery.toQuery().toString());
     };
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java
index f780072..ade68e3 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java
@@ -40,7 +40,7 @@
 	SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field", "a", "b", "c");
 	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
 	ssaquery.or("d").or(segquery).or("e");
-	assertEquals("spanOr([field:d, spanNear([spanNear([field:a, field:b], -1, false), field:c], -1, false), field:e])", ssaquery.toQuery().toString());
+	assertEquals("spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])", ssaquery.toQuery().toString());
     };
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java
index c4fd3d1..57a9288 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java
@@ -18,10 +18,10 @@
 	assertEquals("field:a", ssquery.toQuery().toString());
 
 	ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
-	assertEquals("spanNear([field:a, field:b], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery().toString());
 
 	ssquery = new SpanSegmentQueryWrapper("field","a", "b", "c");
-	assertEquals("spanNear([spanNear([field:a, field:b], -1, false), field:c], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(spanSegment(field:a, field:b), field:c)", ssquery.toQuery().toString());
     };
 
     @Test
@@ -31,13 +31,13 @@
 	assertEquals("field:a", ssquery.toQuery().toString());
 
 	ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
-	assertEquals("spanNear([field:a, field:b], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery().toString());
 
 	ssquery.without("c");
-	assertEquals("spanNot(spanNear([field:a, field:b], -1, false), field:c)", ssquery.toQuery().toString());
+	assertEquals("spanNot(spanSegment(field:a, field:b), field:c)", ssquery.toQuery().toString());
 
 	ssquery.without("d");
-	assertEquals("spanNot(spanNear([field:a, field:b], -1, false), spanOr([field:c, field:d]))", ssquery.toQuery().toString());
+	assertEquals("spanNot(spanSegment(field:a, field:b), spanOr([field:c, field:d]))", ssquery.toQuery().toString());
     };
 
 
@@ -50,23 +50,23 @@
 
 	ssquery.with(new SpanRegexQueryWrapper("field", "a.*b"));
 
-	assertEquals("spanNear([field:a, SpanMultiTermQueryWrapper(field:/a.*b/)], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/))", ssquery.toQuery().toString());
 
 	ssquery.with("c");
 
-	assertEquals("spanNear([spanNear([field:a, SpanMultiTermQueryWrapper(field:/a.*b/)], -1, false), field:c], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c)", ssquery.toQuery().toString());
 
 	ssquery.with("d").with("e");
 
-	assertEquals("spanNear([spanNear([spanNear([spanNear([field:a, SpanMultiTermQueryWrapper(field:/a.*b/)], -1, false), field:c], -1, false), field:d], -1, false), field:e], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e)", ssquery.toQuery().toString());
 
 	ssquery.without(new SpanRegexQueryWrapper("field", "x.?y"));
 
-	assertEquals("spanNot(spanNear([spanNear([spanNear([spanNear([field:a, SpanMultiTermQueryWrapper(field:/a.*b/)], -1, false), field:c], -1, false), field:d], -1, false), field:e], -1, false), SpanMultiTermQueryWrapper(field:/x.?y/))", ssquery.toQuery().toString());
+	assertEquals("spanNot(spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e), SpanMultiTermQueryWrapper(field:/x.?y/))", ssquery.toQuery().toString());
 
 	ssquery.without(new SpanRegexQueryWrapper("field", "z{5,9}"));
 
-	assertEquals("spanNot(spanNear([spanNear([spanNear([spanNear([field:a, SpanMultiTermQueryWrapper(field:/a.*b/)], -1, false), field:c], -1, false), field:d], -1, false), field:e], -1, false), spanOr([SpanMultiTermQueryWrapper(field:/x.?y/), SpanMultiTermQueryWrapper(field:/z{5,9}/)]))", ssquery.toQuery().toString());
+	assertEquals("spanNot(spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e), spanOr([SpanMultiTermQueryWrapper(field:/x.?y/), SpanMultiTermQueryWrapper(field:/z{5,9}/)]))", ssquery.toQuery().toString());
 
     };
 
@@ -80,14 +80,14 @@
 	ssquery.with(new SpanAlterQueryWrapper("field", "c", "d"));
 	ssquery.with(new SpanRegexQueryWrapper("field", "a.*b"));
 
-	assertEquals("spanNear([spanNear([field:a, spanOr([field:c, field:d])], -1, false), SpanMultiTermQueryWrapper(field:/a.*b/)], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(spanSegment(field:a, spanOr([field:c, field:d])), SpanMultiTermQueryWrapper(field:/a.*b/))", ssquery.toQuery().toString());
     };
 
 
     @Test
     public void spanSegmentCloneQuery () {
 	SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
-	assertEquals("spanNear([field:a, field:b], -1, false)", ssquery.toQuery().toString());
+	assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery().toString());
 
 	SpanSegmentQueryWrapper ssquery2 = new SpanSegmentQueryWrapper("field", ssquery);
 	assertEquals(ssquery.toQuery().toString(), ssquery2.toQuery().toString());
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java
index 840f9f3..753b8b1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java
@@ -35,7 +35,7 @@
 
 	sssq.append(ssq);
 
-	assertEquals("spanNext(spanNext(field:a, field:b), spanNear([spanNear([field:-c, field:-d], -1, false), field:-e], -1, false))", sssq.toQuery().toString());
+	assertEquals("spanNext(spanNext(field:a, field:b), spanSegment(spanSegment(field:-c, field:-d), field:-e))", sssq.toQuery().toString());
 
     };
 
@@ -65,7 +65,7 @@
 
 	sssq.prepend(ssq);
 
-	assertEquals("spanNext(spanNext(spanNear([spanNear([field:-a, field:-b], -1, false), field:-c], -1, false), field:d), field:e)", sssq.toQuery().toString());
+	assertEquals("spanNext(spanNext(spanSegment(spanSegment(field:-a, field:-b), field:-c), field:d), field:e)", sssq.toQuery().toString());
     };
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
index 6002606..2b48eb0 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -62,7 +62,7 @@
 	    new KorapQuery("field1").seg("a").with("b")
         );
 	// query
-	assertEquals(ks.getQuery().toString(), "spanNear([field1:a, field1:b], -1, false)");
+	assertEquals(ks.getQuery().toString(), "spanSegment(field1:a, field1:b)");
     };
 
     @Test