[bugfix] DistanceQuery wrapped now correctly
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
index c145200..7ce869a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
@@ -78,7 +78,7 @@
sb.append(maxDistance);
sb.append("], ");
sb.append( isOrdered ? "ordered, " : "notOrdered, " );
- sb.append( exclusion ? "excluded)]" : "notExcluded)])");
+ sb.append( exclusion ? "excluded)])" : "notExcluded)])");
sb.append(ToStringUtils.boost(getBoost()));
return sb.toString();
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
index e6c0488..abf2ae4 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
@@ -149,7 +149,7 @@
// Create spanElementDistance query
if (!constraint.getUnit().equals("w")) {
for (int i = 1; i < this.segments.size(); i++) {
- query = new SpanDistanceQuery(
+ SpanDistanceQuery sdquery = new SpanDistanceQuery(
new SpanElementQuery(this.field, constraint.getUnit()),
query,
this.segments.get(i),
@@ -158,13 +158,15 @@
this.isInOrder(),
true
);
+ sdquery.setExclusion(constraint.isExclusion());
+ query = (SpanQuery) sdquery;
};
}
// Create spanDistance query
else {
for (int i = 1; i < this.segments.size(); i++) {
- query = new SpanDistanceQuery(
+ SpanDistanceQuery sdquery = new SpanDistanceQuery(
query,
this.segments.get(i),
constraint.getMinDistance(),
@@ -172,6 +174,8 @@
this.isInOrder(),
true
);
+ sdquery.setExclusion(constraint.isExclusion());
+ query = (SpanQuery) sdquery;
};
};
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 6ed797c..77f2e89 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
@@ -194,7 +194,7 @@
@Test
public void KorapSequenceQuery6 () {
KorapQuery kq = new KorapQuery("field");
- SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(2,3,"s",true).toQuery();
+ SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(2,3,"s", true).toQuery();
assertEquals("spanElementDistance(field:try1, field:try2, [(s[2:3], ordered, excluded)])", sq.toString());
};