diff options
author | Geir Storli <geirst@yahooinc.com> | 2023-05-04 07:59:09 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2023-05-04 07:59:09 +0000 |
commit | e75bcce116eadef9d00e86470a99d150aba87db3 (patch) | |
tree | 5bc46ba72f56804cb2b285402d1c67d5a70908ca /container-search/src/test | |
parent | 8506ecab7210283da6aca51a20a258de76d8efc7 (diff) |
Propagate match features to Hit in streaming search.
Diffstat (limited to 'container-search/src/test')
-rw-r--r-- | container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java index 0ecf1db01e5..578ccec7f40 100644 --- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.streamingvisitors; +import com.yahoo.data.access.Inspectable; +import com.yahoo.data.access.helpers.MatchFeatureData; import com.yahoo.document.select.parser.TokenMgrException; import com.yahoo.messagebus.Trace; import com.yahoo.messagebus.routing.Route; @@ -26,6 +28,7 @@ import com.yahoo.vespa.streamingvisitors.tracing.TraceExporter; import org.junit.jupiter.api.Test; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -93,8 +96,12 @@ public class VdsStreamingSearcherTestCase { addResults(USERDOC_ID_PREFIX, 1, false); } else if (queryString.compareTo("onegroupinghit") == 0) { groupings.add(new Grouping()); + } else if (queryString.compareTo("match_features") == 0) { + addResults(USERDOC_ID_PREFIX, 1, false); + var matchFeatures = new MatchFeatureData(Arrays.asList("my_feature")).addHit(); + matchFeatures.set(0, 7.0); + hits.get(0).setMatchFeatures(matchFeatures); } - } private void addResults(String idPrefix, int hitCount, boolean emptyDocsum) { @@ -212,6 +219,16 @@ public class VdsStreamingSearcherTestCase { checkSearch(searcher, queryString, hitCount, null); } + private static void checkMatchFeatures(VdsStreamingSearcher searcher) { + String queryString = "/?streaming.selection=true&query=match_features"; + Result result = executeQuery(searcher, new Query(queryString)); + assertNull(result.hits().getError()); + assertEquals(result.hits().size(), 1); + Hit hit = result.hits().get(0); + var mf = hit.getField("matchfeatures"); + assertEquals(7.0, ((Inspectable) mf).inspect().field("my_feature").asDouble()); + } + @Test void testBasics() { MockVisitorFactory factory = new MockVisitorFactory(); @@ -249,6 +266,8 @@ public class VdsStreamingSearcherTestCase { checkSearch(searcher, "/?streaming.groupname=group1&query=twogrouphitsandoneuserhit", 2, GROUPDOC_ID_PREFIX); checkGrouping(searcher, "/?streaming.selection=true&query=onegroupinghit", 1); + + checkMatchFeatures(searcher); } @Test |