diff options
author | Geir Storli <geirst@yahooinc.com> | 2022-05-05 09:45:21 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2022-05-05 09:45:21 +0000 |
commit | a02b6c3c9ace991c82a9e1509d4d516688973fa5 (patch) | |
tree | 43893cbd69b04d462f04910f3ff1820109de328f /container-search/src/main | |
parent | 11fa502ceff0f4d7b7939289250441b94419eaa5 (diff) |
Name matching query properties using camelCase as done elsewhere.
Also provide the lowercase version as alias for backwards compatibility.
Diffstat (limited to 'container-search/src/main')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java | 21 | ||||
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/ranking/Matching.java | 8 |
2 files changed, 17 insertions, 12 deletions
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 d7c2ef946e9..7d1a62310a3 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 @@ -106,10 +106,10 @@ public class QueryProperties extends Properties { } else if (key.size() == 3 && key.get(1).equals(Ranking.MATCHING)) { Matching matching = ranking.getMatching(); - if (key.last().equals(Matching.TERMWISELIMIT)) return matching.getTermwiseLimit(); - if (key.last().equals(Matching.NUMTHREADSPERSEARCH)) return matching.getNumThreadsPerSearch(); - if (key.last().equals(Matching.NUMSEARCHPARTITIIONS)) return matching.getNumSearchPartitions(); - if (key.last().equals(Matching.MINHITSPERTHREAD)) return matching.getMinHitsPerThread(); + if (equalsWithLowerCaseAlias(key.last(), Matching.TERMWISELIMIT)) return matching.getTermwiseLimit(); + if (equalsWithLowerCaseAlias(key.last(), Matching.NUMTHREADSPERSEARCH)) return matching.getNumThreadsPerSearch(); + if (equalsWithLowerCaseAlias(key.last(), Matching.NUMSEARCHPARTITIIONS)) return matching.getNumSearchPartitions(); + if (equalsWithLowerCaseAlias(key.last(), Matching.MINHITSPERTHREAD)) return matching.getMinHitsPerThread(); } else if (key.size() > 2) { @@ -250,13 +250,13 @@ public class QueryProperties extends Properties { } else if (key.size() == 3 && key.get(1).equals(Ranking.MATCHING)) { Matching matching = ranking.getMatching(); - if (key.last().equals(Matching.TERMWISELIMIT)) + if (equalsWithLowerCaseAlias(key.last(), Matching.TERMWISELIMIT)) matching.setTermwiselimit(asDouble(value, 1.0)); - else if (key.last().equals(Matching.NUMTHREADSPERSEARCH)) + else if (equalsWithLowerCaseAlias(key.last(), Matching.NUMTHREADSPERSEARCH)) matching.setNumThreadsPerSearch(asInteger(value, 1)); - else if (key.last().equals(Matching.NUMSEARCHPARTITIIONS)) + else if (equalsWithLowerCaseAlias(key.last(), Matching.NUMSEARCHPARTITIIONS)) matching.setNumSearchPartitions(asInteger(value, 1)); - else if (key.last().equals(Matching.MINHITSPERTHREAD)) + else if (equalsWithLowerCaseAlias(key.last(), Matching.MINHITSPERTHREAD)) matching.setMinHitsPerThread(asInteger(value, 0)); else if (key.last().equals(Matching.POST_FILTER_THRESHOLD)) matching.setPostFilterThreshold(asDouble(value, 1.0)); @@ -398,6 +398,11 @@ public class QueryProperties extends Properties { "'. See the query api for valid keys starting by '" + namespace + "'."); } + private boolean equalsWithLowerCaseAlias(String key, String property) { + // The lowercase alias is used to provide backwards compatibility of a query property that was wrongly named in the first place. + return key.equals(property) || key.equals(property.toLowerCase()); + } + @Override public final Query getParentQuery() { return query; 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 65b4b62f132..35fbd52f967 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 @@ -18,10 +18,10 @@ public class Matching implements Cloneable { /** The type representing the property arguments consumed by this */ private static final QueryProfileType argumentType; - public static final String TERMWISELIMIT = "termwiselimit"; - public static final String NUMTHREADSPERSEARCH = "numthreadspersearch"; - public static final String NUMSEARCHPARTITIIONS = "numsearchpartitions"; - public static final String MINHITSPERTHREAD = "minhitsperthread"; + public static final String TERMWISELIMIT = "termwiseLimit"; + 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"; |