diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-05-30 09:15:58 +0000 |
---|---|---|
committer | Arne H Juul <arnej27959@users.noreply.github.com> | 2022-06-01 08:46:41 +0200 |
commit | 65dab7595a4416b37517372f978222e7ded6f3fa (patch) | |
tree | 648fa969b773bb837b866f53c97072d340b11b54 /container-search | |
parent | f68838b632e8af9cad24568bd5354ed1db0aa685 (diff) |
backwards compatibility
if pos.radius is negative, add the geoLocation item as rank-only
Diffstat (limited to 'container-search')
3 files changed, 19 insertions, 1 deletions
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json index b4ac714b9d2..923081d6d34 100644 --- a/container-search/abi-spec.json +++ b/container-search/abi-spec.json @@ -5363,6 +5363,7 @@ "public void addItem(com.yahoo.prelude.query.Item)", "public void addItem(int, com.yahoo.prelude.query.Item)", "public boolean isEmpty()", + "public com.yahoo.prelude.query.Item rankWith(com.yahoo.prelude.query.Item)", "public com.yahoo.prelude.query.Item and(com.yahoo.prelude.query.Item)", "public static java.util.List getPositiveTerms(com.yahoo.prelude.query.Item)", "public int treeSize()", diff --git a/container-search/src/main/java/com/yahoo/search/query/QueryTree.java b/container-search/src/main/java/com/yahoo/search/query/QueryTree.java index 0655727b46b..d97a464aa7a 100644 --- a/container-search/src/main/java/com/yahoo/search/query/QueryTree.java +++ b/container-search/src/main/java/com/yahoo/search/query/QueryTree.java @@ -110,6 +110,19 @@ public class QueryTree extends CompositeItem { // -------------- Facade /** + * Modifies this query to become the current query RANK with the given item. + * + * @return the resulting root item in this + */ + public Item rankWith(Item item) { + var result = new RankItem(); + result.addItem(getRoot()); + result.addItem(item); + setRoot(result); + return result; + } + + /** * Modifies this query to become the current query AND the given item. * * @return the resulting root item in this diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/DefaultPositionSearcher.java b/container-search/src/main/java/com/yahoo/search/querytransform/DefaultPositionSearcher.java index d3b166e03d0..8fae90849e5 100644 --- a/container-search/src/main/java/com/yahoo/search/querytransform/DefaultPositionSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/querytransform/DefaultPositionSearcher.java @@ -56,7 +56,11 @@ public class DefaultPositionSearcher extends Searcher { } if (useV8GeoPositions && (location != null) && (location.getAttribute() != null)) { var geoLoc = new GeoLocationItem(location); - query.getModel().getQueryTree().and(geoLoc); + if (location.isGeoCircle() && location.degRadius() < 0) { + query.getModel().getQueryTree().rankWith(geoLoc); + } else { + query.getModel().getQueryTree().and(geoLoc); + } location = null; query.getRanking().setLocation(location); } |