aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
Diffstat (limited to 'container-search')
-rw-r--r--container-search/abi-spec.json16
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/ranking/Matching.java81
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java17
4 files changed, 71 insertions, 47 deletions
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json
index b4c4537a708..54a3b3a0f36 100644
--- a/container-search/abi-spec.json
+++ b/container-search/abi-spec.json
@@ -6851,18 +6851,22 @@
"methods": [
"public void <init>()",
"public static com.yahoo.search.query.profile.types.QueryProfileType getArgumentType()",
+ "public java.lang.Double getTermwiseLimit()",
+ "public java.lang.Integer getNumThreadsPerSearch()",
"public java.lang.Integer getNumSearchPartitions()",
- "public void setNumSearchPartitions(int)",
"public java.lang.Integer getMinHitsPerThread()",
- "public void setMinHitsPerThread(int)",
+ "public java.lang.Double getPostFilterThreshold()",
+ "public java.lang.Double getApproximateThreshold()",
"public void setTermwiselimit(double)",
- "public java.lang.Double getTermwiseLimit()",
"public void setNumThreadsPerSearch(int)",
- "public java.lang.Integer getNumThreadsPerSearch()",
+ "public void setNumSearchPartitions(int)",
+ "public void setMinHitsPerThread(int)",
+ "public void setPostFilterThreshold(double)",
+ "public void setApproximateThreshold(double)",
"public void prepare(com.yahoo.search.query.ranking.RankProperties)",
"public com.yahoo.search.query.ranking.Matching clone()",
- "public int hashCode()",
"public boolean equals(java.lang.Object)",
+ "public int hashCode()",
"public bridge synthetic java.lang.Object clone()"
],
"fields": [
@@ -6870,6 +6874,8 @@
"public static final java.lang.String NUMTHREADSPERSEARCH",
"public static final java.lang.String NUMSEARCHPARTITIIONS",
"public static final java.lang.String MINHITSPERTHREAD",
+ "public static final java.lang.String POST_FILTER_THRESHOLD",
+ "public static final java.lang.String APPROXIMATE_THRESHOLD",
"public java.lang.Double termwiseLimit"
]
},
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
index cf9209dcc0d..0fd11d9edd7 100644
--- a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
@@ -263,6 +263,10 @@ public class QueryProperties extends Properties {
matching.setNumSearchPartitions(asInteger(value, 1));
else if (key.last().equals(Matching.MINHITSPERTHREAD))
matching.setMinHitsPerThread(asInteger(value, 0));
+ else if (key.last().equals(Matching.POST_FILTER_THRESHOLD))
+ matching.setPostFilterThreshold(asDouble(value, 1.0));
+ else if (key.last().equals(Matching.APPROXIMATE_THRESHOLD))
+ matching.setApproximateThreshold(asDouble(value, 0.05));
else
throwIllegalParameter(key.rest().toString(), Ranking.MATCHING);
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/ranking/Matching.java b/container-search/src/main/java/com/yahoo/search/query/ranking/Matching.java
index 38dcdfae9fb..65b4b62f132 100644
--- a/container-search/src/main/java/com/yahoo/search/query/ranking/Matching.java
+++ b/container-search/src/main/java/com/yahoo/search/query/ranking/Matching.java
@@ -22,7 +22,8 @@ public class Matching implements Cloneable {
public static final String NUMTHREADSPERSEARCH = "numthreadspersearch";
public static final String NUMSEARCHPARTITIIONS = "numsearchpartitions";
public static final String MINHITSPERTHREAD = "minhitsperthread";
-
+ public static final String POST_FILTER_THRESHOLD = "postFilterThreshold";
+ public static final String APPROXIMATE_THRESHOLD = "approximateThreshold";
static {
argumentType =new QueryProfileType(Ranking.MATCHING);
@@ -32,6 +33,8 @@ public class Matching implements Cloneable {
argumentType.addField(new FieldDescription(NUMTHREADSPERSEARCH, "integer"));
argumentType.addField(new FieldDescription(NUMSEARCHPARTITIIONS, "integer"));
argumentType.addField(new FieldDescription(MINHITSPERTHREAD, "integer"));
+ argumentType.addField(new FieldDescription(POST_FILTER_THRESHOLD, "double"));
+ argumentType.addField(new FieldDescription(APPROXIMATE_THRESHOLD, "double"));
argumentType.freeze();
}
@@ -41,22 +44,15 @@ public class Matching implements Cloneable {
private Integer numThreadsPerSearch = null;
private Integer numSearchPartitions = null;
private Integer minHitsPerThread = null;
+ private Double postFilterThreshold = null;
+ private Double approximateThreshold = null;
- public Integer getNumSearchPartitions() {
- return numSearchPartitions;
- }
-
- public void setNumSearchPartitions(int numSearchPartitions) {
- this.numSearchPartitions = numSearchPartitions;
- }
-
- public Integer getMinHitsPerThread() {
- return minHitsPerThread;
- }
-
- public void setMinHitsPerThread(int minHitsPerThread) {
- this.minHitsPerThread = minHitsPerThread;
- }
+ public Double getTermwiseLimit() { return termwiseLimit; }
+ public Integer getNumThreadsPerSearch() { return numThreadsPerSearch; }
+ public Integer getNumSearchPartitions() { return numSearchPartitions; }
+ public Integer getMinHitsPerThread() { return minHitsPerThread; }
+ public Double getPostFilterThreshold() { return postFilterThreshold; }
+ public Double getApproximateThreshold() { return approximateThreshold; }
public void setTermwiselimit(double value) {
if ((value < 0.0) || (value > 1.0)) {
@@ -64,14 +60,21 @@ public class Matching implements Cloneable {
}
termwiseLimit = value;
}
-
- public Double getTermwiseLimit() { return termwiseLimit; }
-
public void setNumThreadsPerSearch(int value) {
numThreadsPerSearch = value;
}
- public Integer getNumThreadsPerSearch() { return numThreadsPerSearch; }
-
+ public void setNumSearchPartitions(int value) {
+ numSearchPartitions = value;
+ }
+ public void setMinHitsPerThread(int value) {
+ minHitsPerThread = value;
+ }
+ public void setPostFilterThreshold(double threshold) {
+ postFilterThreshold = threshold;
+ }
+ public void setApproximateThreshold(double threshold) {
+ approximateThreshold = threshold;
+ }
/** Internal operation - DO NOT USE */
public void prepare(RankProperties rankProperties) {
@@ -88,6 +91,12 @@ public class Matching implements Cloneable {
if (minHitsPerThread != null) {
rankProperties.put("vespa.matching.minhitsperthread", String.valueOf(minHitsPerThread));
}
+ if (postFilterThreshold != null) {
+ rankProperties.put("vespa.matching.global_filter.upper_limit", String.valueOf(postFilterThreshold));
+ }
+ if (approximateThreshold != null) {
+ rankProperties.put("vespa.matching.global_filter.lower_limit", String.valueOf(approximateThreshold));
+ }
}
@Override
@@ -101,27 +110,21 @@ public class Matching implements Cloneable {
}
@Override
- public int hashCode() {
- int hash = 0;
- if (termwiseLimit != null) hash += 11 * termwiseLimit.hashCode();
- if (numThreadsPerSearch != null) hash += 13 * numThreadsPerSearch.hashCode();
- if (numSearchPartitions != null) hash += 17 * numSearchPartitions.hashCode();
- if (minHitsPerThread != null) hash += 19 * minHitsPerThread.hashCode();
- return hash;
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Matching matching = (Matching) o;
+ return Objects.equals(termwiseLimit, matching.termwiseLimit) &&
+ Objects.equals(numThreadsPerSearch, matching.numThreadsPerSearch) &&
+ Objects.equals(numSearchPartitions, matching.numSearchPartitions) &&
+ Objects.equals(minHitsPerThread, matching.minHitsPerThread) &&
+ Objects.equals(postFilterThreshold, matching.postFilterThreshold) &&
+ Objects.equals(approximateThreshold, matching.approximateThreshold);
}
@Override
- public boolean equals(Object o) {
- if (o == this) return true;
- if ( ! (o instanceof Matching)) return false;
-
- Matching other = (Matching) o;
- if ( ! Objects.equals(this.termwiseLimit, other.termwiseLimit)) return false;
- if ( ! Objects.equals(this.numThreadsPerSearch, other.numThreadsPerSearch)) return false;
- if ( ! Objects.equals(this.numSearchPartitions, other.numSearchPartitions)) return false;
- if ( ! Objects.equals(this.minHitsPerThread, other.minHitsPerThread)) return false;
- return true;
+ public int hashCode() {
+ return Objects.hash(termwiseLimit, numThreadsPerSearch, numSearchPartitions, minHitsPerThread, postFilterThreshold, approximateThreshold);
}
-
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
index d4de8dba9dd..d117f88aa6a 100644
--- a/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
@@ -19,22 +19,33 @@ public class MatchingTestCase {
assertNull(query.getRanking().getMatching().getNumThreadsPerSearch());
assertNull(query.getRanking().getMatching().getNumSearchPartitions());
assertNull(query.getRanking().getMatching().getMinHitsPerThread());
-
+ assertNull(query.getRanking().getMatching().getPostFilterThreshold());
+ assertNull(query.getRanking().getMatching().getApproximateThreshold());
}
@Test
- public void testQueryOverride() {
- Query query = new Query("?query=test&ranking.matching.termwiselimit=0.7&ranking.matching.numthreadspersearch=17&ranking.matching.numsearchpartitions=13&ranking.matching.minhitsperthread=3");
+ public void testQueryOverrides() {
+ Query query = new Query("?query=test" +
+ "&ranking.matching.termwiselimit=0.7" +
+ "&ranking.matching.numthreadspersearch=17" +
+ "&ranking.matching.numsearchpartitions=13" +
+ "&ranking.matching.minhitsperthread=3" +
+ "&ranking.matching.postFilterThreshold=0.8" +
+ "&ranking.matching.approximateThreshold=0.3");
assertEquals(Double.valueOf(0.7), query.getRanking().getMatching().getTermwiseLimit());
assertEquals(Integer.valueOf(17), query.getRanking().getMatching().getNumThreadsPerSearch());
assertEquals(Integer.valueOf(13), query.getRanking().getMatching().getNumSearchPartitions());
assertEquals(Integer.valueOf(3), query.getRanking().getMatching().getMinHitsPerThread());
+ assertEquals(Double.valueOf(0.8), query.getRanking().getMatching().getPostFilterThreshold());
+ assertEquals(Double.valueOf(0.3), query.getRanking().getMatching().getApproximateThreshold());
query.prepare();
assertEquals("0.7", query.getRanking().getProperties().get("vespa.matching.termwise_limit").get(0));
assertEquals("17", query.getRanking().getProperties().get("vespa.matching.numthreadspersearch").get(0));
assertEquals("13", query.getRanking().getProperties().get("vespa.matching.numsearchpartitions").get(0));
assertEquals("3", query.getRanking().getProperties().get("vespa.matching.minhitsperthread").get(0));
+ assertEquals("0.8", query.getRanking().getProperties().get("vespa.matching.global_filter.upper_limit").get(0));
+ assertEquals("0.3", query.getRanking().getProperties().get("vespa.matching.global_filter.lower_limit").get(0));
}
private void verifyException(String key, String value) {