Move collectPayloads to SimpleSpanQuery
diff --git a/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java b/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
index d0ffdba..d7dcc02 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
@@ -15,11 +15,13 @@
* */
public abstract class SimpleSpanQuery extends SpanQuery implements Cloneable{
- private SpanQuery firstClause, secondClause;
+ protected SpanQuery firstClause, secondClause;
private String field;
private String spanName;
+ protected boolean collectPayloads;
- public SimpleSpanQuery(SpanQuery firstClause, SpanQuery secondClause, String spanName) {
+ public SimpleSpanQuery(SpanQuery firstClause, SpanQuery secondClause,
+ String spanName, boolean collectPayloads) {
this.field = secondClause.getField();
if (!firstClause.getField().equals(field)){
throw new IllegalArgumentException("Clauses must have the same field.");
@@ -27,6 +29,7 @@
this.setFirstClause(firstClause);
this.setSecondClause(secondClause);
this.spanName=spanName;
+ this.collectPayloads = collectPayloads;
}
@Override
@@ -61,10 +64,17 @@
public void setSecondClause(SpanQuery secondClause) {
this.secondClause = secondClause;
+ }
+
+ public boolean isCollectPayloads() {
+ return collectPayloads;
}
-
+
+ public void setCollectPayloads(boolean collectPayloads) {
+ this.collectPayloads = collectPayloads;
+ }
+
// For rewriting fuzzy searches like wildcard and regex
-
@Override
public void extractTerms(Set<Term> terms) {
firstClause.extractTerms(terms);
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 e219818..1915336 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
@@ -23,33 +23,26 @@
* */
public class SpanDistanceQuery extends SimpleSpanQuery {
- protected int minDistance, maxDistance;
- public boolean isOrdered, collectPayloads;
- protected SpanQuery firstClause, secondClause;
+ public boolean isOrdered;
+ protected int minDistance, maxDistance;
private SpanQuery elementQuery; // element distance unit
public SpanDistanceQuery(SpanQuery firstClause, SpanQuery secondClause,
int minDistance, int maxDistance, boolean isOrdered,
boolean collectPayloads) {
- super(firstClause, secondClause, "spanDistance");
- this.firstClause=firstClause;
- this.secondClause=secondClause;
+ super(firstClause, secondClause, "spanDistance",collectPayloads);
this.minDistance =minDistance;
this.maxDistance = maxDistance;
this.isOrdered = isOrdered;
- this.collectPayloads = collectPayloads;
}
public SpanDistanceQuery(SpanQuery elementQuery, SpanQuery firstClause,
SpanQuery secondClause, int minDistance, int maxDistance,
boolean isOrdered, boolean collectPayloads) {
- super(firstClause, secondClause, "spanElementDistance");
- this.firstClause=firstClause;
- this.secondClause=secondClause;
+ super(firstClause, secondClause, "spanElementDistance",collectPayloads);
this.minDistance =minDistance;
this.maxDistance = maxDistance;
this.isOrdered = isOrdered;
- this.collectPayloads = collectPayloads;
this.elementQuery = elementQuery;
}
@@ -103,14 +96,6 @@
public void setMaxDistance(int maxDistance) {
this.maxDistance = maxDistance;
}
-
- public boolean isCollectPayloads() {
- return collectPayloads;
- }
-
- public void setCollectPayloads(boolean collectPayloads) {
- this.collectPayloads = collectPayloads;
- }
public SpanQuery getElementQuery() {
return elementQuery;
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
index 4fac9e6..60e9a2c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
@@ -21,20 +21,15 @@
* */
public class SpanMultipleDistanceQuery extends SimpleSpanQuery{
- private SpanQuery firstClause, secondClause;
private List<DistanceConstraint> constraints;
private boolean isOrdered;
- private boolean collectPayloads;
public SpanMultipleDistanceQuery(SpanQuery firstClause, SpanQuery secondClause,
List<DistanceConstraint> constraints, boolean isOrdered,
boolean collectPayloads) {
- super(firstClause, secondClause, "spanMultipleDistance");
+ super(firstClause, secondClause, "spanMultipleDistance",collectPayloads);
this.constraints = constraints;
- this.firstClause=firstClause;
- this.secondClause=secondClause;
this.isOrdered = isOrdered;
- this.collectPayloads = collectPayloads;
}
@Override
@@ -44,7 +39,7 @@
(SpanQuery) secondClause.clone(),
this.constraints,
this.isOrdered,
- this.collectPayloads
+ collectPayloads
);
query.setBoost(getBoost());
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
index f7a9e19..68d35f8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
@@ -22,9 +22,6 @@
* This is identical to a phrase query with exactly two clauses.
*/
public class SpanNextQuery extends SimpleSpanQuery implements Cloneable {
- private SpanQuery firstClause;
- private SpanQuery secondClause;
- private boolean collectPayloads;
// Constructor
public SpanNextQuery(SpanQuery firstClause, SpanQuery secondClause) {
@@ -34,10 +31,7 @@
// Constructor
public SpanNextQuery(SpanQuery firstClause, SpanQuery secondClause,
boolean collectPayloads) {
- super(firstClause, secondClause, "spanNext");
- this.collectPayloads = collectPayloads;
- this.firstClause = firstClause;
- this.secondClause = secondClause;
+ super(firstClause, secondClause, "spanNext",collectPayloads);
};
@@ -53,7 +47,7 @@
SpanNextQuery spanNextQuery = new SpanNextQuery(
(SpanQuery) firstClause.clone(),
(SpanQuery) secondClause.clone(),
- this.collectPayloads
+ collectPayloads
);
spanNextQuery.setBoost(getBoost());
return spanNextQuery;
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
index 3f7e487..632c6f6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
@@ -19,19 +19,13 @@
* */
public class SpanSegmentQuery extends SimpleSpanQuery{
- private boolean collectPayloads;
- private SpanQuery firstClause, secondClause;
-
public SpanSegmentQuery(SpanQuery firstClause, SpanQuery secondClause) {
this(firstClause,secondClause,true);
}
public SpanSegmentQuery(SpanQuery firstClause, SpanQuery secondClause,
boolean collectPayloads) {
- super(firstClause,secondClause,"spanSegment");
- this.collectPayloads = collectPayloads;
- this.firstClause=firstClause;
- this.secondClause=secondClause;
+ super(firstClause,secondClause,"spanSegment",collectPayloads);
}
@Override
@@ -46,7 +40,7 @@
SpanSegmentQuery spanSegmentQuery = new SpanSegmentQuery(
(SpanQuery) firstClause.clone(),
(SpanQuery) secondClause.clone(),
- this.collectPayloads
+ collectPayloads
);
spanSegmentQuery.setBoost(getBoost());
return spanSegmentQuery;
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java
index aedd6c1..b2f923e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java
@@ -1,8 +1,6 @@
package de.ids_mannheim.korap.query.spans;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import org.apache.lucene.index.AtomicReaderContext;
@@ -14,7 +12,6 @@
import org.slf4j.LoggerFactory;
import de.ids_mannheim.korap.query.SimpleSpanQuery;
-import de.ids_mannheim.korap.query.SpanDistanceQuery;
/** DistanceSpan is a base class for enumeration of span matches,
* whose two child spans have a specific range of distance (within