summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java17
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg4
3 files changed, 42 insertions, 1 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
index e5e46f21a2a..2090390890e 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
@@ -3,6 +3,8 @@ package com.yahoo.prelude.fastsearch;
import com.yahoo.collections.TinyIdentitySet;
import com.yahoo.fs4.DocsumPacket;
+import com.yahoo.prelude.query.CompositeItem;
+import com.yahoo.prelude.query.GeoLocationItem;
import com.yahoo.prelude.query.Item;
import com.yahoo.prelude.query.NullItem;
import com.yahoo.prelude.query.textualrepresentation.TextualQueryRepresentation;
@@ -74,6 +76,19 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
protected abstract void doPartialFill(Result result, String summaryClass);
+ private boolean hasLocation(Item tree) {
+ if (tree instanceof GeoLocationItem) {
+ return true;
+ }
+ if (tree instanceof CompositeItem) {
+ var composite = (CompositeItem)tree;
+ for (Item child : composite.items()) {
+ if (hasLocation(child)) return true;
+ }
+ }
+ return false;
+ }
+
/**
* Returns whether we need to send the query when fetching summaries.
* This is necessary if the query requests summary features or dynamic snippeting
@@ -87,6 +102,8 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
DocsumDefinition docsumDefinition = documentDb.getDocsumDefinitionSet().getDocsum(query.getPresentation().getSummary());
if (docsumDefinition.isDynamic()) return true;
+ if (hasLocation(query.getModel().getQueryTree())) return true;
+
// Needed to generate ranking features?
RankProfile rankProfile = documentDb.rankProfiles().get(query.getRanking().getProfile());
if (rankProfile == null) return true; // stay safe
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
index 63475c9c189..9e45c7ef245 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
@@ -3,6 +3,7 @@ package com.yahoo.prelude.fastsearch.test;
import com.google.common.collect.ImmutableList;
import com.yahoo.component.chain.Chain;
+import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.container.handler.VipStatus;
import com.yahoo.container.protect.Error;
@@ -11,6 +12,7 @@ import com.yahoo.prelude.fastsearch.ClusterParams;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.prelude.fastsearch.FastSearcher;
import com.yahoo.prelude.fastsearch.SummaryParameters;
+import com.yahoo.prelude.fastsearch.VespaBackEndSearcher;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
@@ -32,6 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -105,6 +108,25 @@ public class FastSearcherTestCase {
}
@Test
+ public void testSummaryNeedsQuery() {
+ ConfigGetter<DocumentdbInfoConfig> getter = new ConfigGetter<>(DocumentdbInfoConfig.class);
+ DocumentdbInfoConfig config = getter.getConfig("file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg");
+ FastSearcher backend = new FastSearcher("container.0",
+ MockDispatcher.create(Collections.singletonList(new Node(0, "host0", 0))),
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ config);
+ Query q = new Query("?query=foo");
+ Result result = doSearch(backend, q, 0, 10);
+ assertFalse(backend.summaryNeedsQuery(q));
+
+ q = new Query("?query=select+*+from+source+where+title+contains+%22foobar%22+and++geoLocation%28myfieldname%2C+63.5%2C+10.5%2C+%22999+km%22%29%3B");
+ q.getModel().setType(Query.Type.YQL);
+ result = doSearch(backend, q, 0, 10);
+ assertTrue(backend.summaryNeedsQuery(q));
+ }
+
+ @Test
public void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
MockDispatcher dispatcher = MockDispatcher.create(ImmutableList.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg
index f69e0ed7a54..cc65ab2565e 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg
@@ -348,4 +348,6 @@ documentdb[0].summaryclass[6].fields[29].name URLLIST
documentdb[0].summaryclass[6].fields[29].type string
documentdb[0].summaryclass[6].fields[30].name WORDS
documentdb[0].summaryclass[6].fields[30].type integer
-documentdb[0].rankprofile[0]
+documentdb[0].rankprofile[0].name "default"
+documentdb[0].rankprofile[0].hasSummaryFeatures false
+documentdb[0].rankprofile[0].hasRankFeatures false