summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-10-16 16:25:09 +0200
committerGitHub <noreply@github.com>2018-10-16 16:25:09 +0200
commit262bcf2ba8983a2edd2c67bab8117696e25156c3 (patch)
tree823860e1f0b8014493322784afdc346b2d3237aa /container-search
parentf3f0aad682088dfa46c8c677ace04a8bbdea8865 (diff)
parent75938aee2f1b99ab544cd0bac37da87ae2364e78 (diff)
Merge pull request #7319 from vespa-engine/bratseth/remove-deprecated-api-usage
Bratseth/remove deprecated api usage
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/Index.java41
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/IndexFacts.java18
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/IndexModel.java102
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/Pong.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java37
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java5
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/Context.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java4
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/GenericTemplateSet.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java4
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/LogExceptionUserTemplateDelegator.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/Template.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/TemplateSet.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/Query.java9
-rw-r--r--container-search/src/main/java/com/yahoo/search/Result.java19
-rw-r--r--container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPClientSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPProviderSearcher.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredSearcherHelper.java1
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/Connection.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/GzipDecompressingEntity.java5
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/HTTPClientSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/HTTPParameters.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/HTTPProviderSearcher.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/HTTPSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/TimedHttpEntity.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/TimedStream.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/http/TimeoutException.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/vespa/QueryMarshaller.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/vespa/ResultBuilder.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/vespa/VespaSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java6
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java46
-rw-r--r--container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplate.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplateSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/pagetemplates/model/PageElement.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/pagetemplates/result/PageTemplatesXmlRenderer.java334
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/Model.java9
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/Presentation.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/QueryCombinator.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java11
-rw-r--r--container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java18
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/Coverage.java18
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/DefaultErrorHit.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/ErrorHit.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/Hit.java35
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/HitGroup.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/Templating.java9
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/model/federation/HttpProviderSpec.java4
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java9
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java43
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java100
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/IndexCombinatorTestCase.java176
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/ErrorHitRenderTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java62
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java5
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java17
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceResult.xml70
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersResult.xml51
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsResult.xml47
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java47
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesResult.xml28
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesResult.xml87
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java39
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsResult.xml167
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsResult.xml123
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageResult.xml4
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java21
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingResult.xml4
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java23
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererResult.xml4
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java21
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceResult.xml2
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java23
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesResult.xml119
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java56
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java282
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java7
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java5
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/test/DefaultErrorHitTestCase.java41
-rw-r--r--container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java8
102 files changed, 1491 insertions, 1242 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/Index.java b/container-search/src/main/java/com/yahoo/prelude/Index.java
index c9781fba76d..109ecfd29f8 100644
--- a/container-search/src/main/java/com/yahoo/prelude/Index.java
+++ b/container-search/src/main/java/com/yahoo/prelude/Index.java
@@ -4,7 +4,10 @@ package com.yahoo.prelude;
import com.yahoo.language.process.StemMode;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
@@ -43,6 +46,10 @@ public class Index {
public static final Index nullIndex = new Index("(null)");
private String name;
+
+ private List<String> aliases = new ArrayList<>();
+
+ // The state resulting from adding commands to this (using addCommand)
private boolean uriIndex = false;
private boolean hostIndex = false;
private StemMode stemMode = StemMode.NONE;
@@ -60,28 +67,28 @@ public class Index {
private boolean numerical = false;
private long predicateUpperBound = Long.MAX_VALUE;
private long predicateLowerBound = Long.MIN_VALUE;
-
- /**
- * True if this is an <i>exact</i> index - which should match
- * tokens containing any characters
- */
+ /** True if this is an <i>exact</i> index - which should match tokens containing any characters */
private boolean exact = false;
-
private boolean isNGram = false;
private int gramSize=2;
-
- /**
- * The string terminating an exact token in this index,
- * or null to use the default (space)
- */
+ /** The string terminating an exact token in this index, or null to use the default (space) */
private String exactTerminator = null;
+ /** Commands which are not coverted into a field */
private Set<String> commands = new java.util.HashSet<>();
+ /** All the commands added to this, including those converted to fields above */
+ private List<String> allCommands = new java.util.ArrayList<>();
+
public Index(String name) {
this.name = name;
}
+ public void addAlias(String alias) { aliases.add(alias); }
+
+ /** Returns an unmodifiable list of the aliases of this index (not including the index proper name) */
+ public List<String> aliases() { return Collections.unmodifiableList(aliases); }
+
/**
* Returns the canonical name of this index, unless it
* is the null index, which doesn't have a canonical name
@@ -128,6 +135,8 @@ public class Index {
/** Adds a type or untyped command string to this */
public Index addCommand(String commandString) {
+ allCommands.add(commandString);
+
if ("fullurl".equals(commandString)) {
setUriIndex(true);
} else if ("urlhost".equals(commandString)) {
@@ -151,7 +160,7 @@ public class Index {
} else if (commandString.startsWith("exact ")) {
setExact(true, commandString.substring(6));
} else if (commandString.startsWith("ngram ")) {
- setNGram(true,Integer.parseInt(commandString.substring(6)));
+ setNGram(true, Integer.parseInt(commandString.substring(6)));
} else if (commandString.equals("attribute")) {
setAttribute(true);
} else if (commandString.equals("default-position")) {
@@ -189,7 +198,6 @@ public class Index {
} else {
predicateUpperBound = Long.MAX_VALUE;
}
-
}
/**
@@ -245,8 +253,8 @@ public class Index {
public int getGramSize() { return gramSize; }
public void setNGram(boolean nGram,int gramSize) {
- this.isNGram=nGram;
- this.gramSize=gramSize;
+ this.isNGram = nGram;
+ this.gramSize = gramSize;
}
public void setDynamicSummary(boolean dynamicSummary) { this.dynamicSummary=dynamicSummary; }
@@ -315,6 +323,9 @@ public class Index {
public long getPredicateLowerBound() { return predicateLowerBound; }
+ /** Returns all the literal command strings given as arguments to addCommand in this instance */
+ public List<String> allCommands() { return allCommands; }
+
@Override
public String toString() {
return "index '" + getName() + "'";
diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
index bdf395c1f0b..448d8e7855f 100644
--- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
+++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
@@ -48,7 +48,7 @@ public class IndexFacts {
* @deprecated do not use
*/
// TODO: Make this package private in Vespa 7
- @Deprecated
+ @Deprecated // OK
public static final String unionName = "unionOfAllKnown";
/** A search definition which contains the union of all settings. */
@@ -64,8 +64,9 @@ public class IndexFacts {
@SuppressWarnings({"deprecation"})
public IndexFacts(IndexModel indexModel) {
- if (indexModel.getSearchDefinitions() != null && indexModel.getUnionSearchDefinition() != null) {
- setSearchDefinitions(indexModel.getSearchDefinitions(), indexModel.getUnionSearchDefinition());
+ if (indexModel.getSearchDefinitions() != null) {
+ this.searchDefinitions = indexModel.getSearchDefinitions();
+ this.unionSearchDefinition = indexModel.getUnionSearchDefinition();
}
if (indexModel.getMasterClusters() != null) {
setMasterClusters(indexModel.getMasterClusters());
@@ -107,7 +108,11 @@ public class IndexFacts {
/**
* Public only for testing.
+ *
+ * @deprecated set at creation time
*/
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public void setClusters(Map<String, List<String>> clusters) {
ensureNotFrozen();
this.clusters = clusters;
@@ -118,7 +123,7 @@ public class IndexFacts {
* @deprecated set indexes at creation time instead
*/
// TODO: Remove on Vespa 7
- @Deprecated
+ @Deprecated // OK
public void setSearchDefinitions(Map<String, SearchDefinition> searchDefinitions,
SearchDefinition unionSearchDefinition) {
ensureNotFrozen();
@@ -182,6 +187,7 @@ public class IndexFacts {
}
DocumentTypeListOffset sd = chooseSearchDefinition(documentTypes, 0);
+
while (sd != null) {
Index index = sd.searchDefinition.getIndex(canonicName);
@@ -318,7 +324,7 @@ public class IndexFacts {
* @deprecated set indexes at creation time instead
*/
// TODO: Remove on Vespa 7
- @Deprecated
+ @Deprecated // OK
public void addIndex(String sdName, String indexName) {
ensureNotFrozen();
@@ -341,7 +347,7 @@ public class IndexFacts {
* @deprecated set indexes at creation time instead
*/
// TODO: Remove on Vespa 7
- @Deprecated
+ @Deprecated // OK
public void addIndex(String sdName, Index index) {
ensureNotFrozen();
diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexModel.java b/container-search/src/main/java/com/yahoo/prelude/IndexModel.java
index 4be337f7f32..45214d4d3df 100644
--- a/container-search/src/main/java/com/yahoo/prelude/IndexModel.java
+++ b/container-search/src/main/java/com/yahoo/prelude/IndexModel.java
@@ -2,13 +2,13 @@
package com.yahoo.prelude;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.logging.Logger;
+import java.util.stream.Collectors;
-import com.yahoo.log.LogLevel;
import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.container.QrSearchersConfig;
@@ -16,19 +16,28 @@ import com.yahoo.container.QrSearchersConfig;
* Parameter class used for construction IndexFacts.
*
* @author Steinar Knutsen
+ * @author bratseth
*/
public final class IndexModel {
- private static final Logger log = Logger.getLogger(IndexModel.class.getName());
-
- // Copied from MasterClustersInfoUpdater. It's a temporary workaround for IndexFacts.
+ // Copied from MasterClustersInfoUpdater. It's a temporary workaround for IndexFacts
private Map<String, List<String>> masterClusters;
private Map<String, SearchDefinition> searchDefinitions;
private SearchDefinition unionSearchDefinition;
/**
+ * Create an index model.
+ */
+ public IndexModel(Map<String, List<String>> masterClusters, Collection<SearchDefinition> searchDefinitions) {
+ this.masterClusters = masterClusters;
+ this.searchDefinitions = searchDefinitions.stream().collect(Collectors.toMap(sd -> sd.getName(), sd -> sd));
+ this.unionSearchDefinition = unionOf(searchDefinitions);
+ }
+
+ /**
* Use IndexModel as a pure wrapper for the parameters given.
*/
+ // TODO: Deprecate on Vespa 7 and remove on Vespa 8
public IndexModel(Map<String, List<String>> masterClusters,
Map<String, SearchDefinition> searchDefinitions,
SearchDefinition unionSearchDefinition) {
@@ -37,9 +46,14 @@ public final class IndexModel {
this.unionSearchDefinition = unionSearchDefinition;
}
+ public IndexModel(IndexInfoConfig indexInfo, QrSearchersConfig clusters) {
+ this(indexInfo, toClusters(clusters));
+ }
+
public IndexModel(IndexInfoConfig indexInfo, Map<String, List<String>> clusters) {
if (indexInfo != null) {
- setDefinitions(indexInfo);
+ searchDefinitions = toSearchDefinitions(indexInfo);
+ unionSearchDefinition = unionOf(searchDefinitions.values());
} else {
searchDefinitions = null;
unionSearchDefinition = null;
@@ -47,89 +61,71 @@ public final class IndexModel {
this.masterClusters = clusters;
}
- public IndexModel(IndexInfoConfig indexInfo, QrSearchersConfig clusters) {
- if (indexInfo != null) {
- setDefinitions(indexInfo);
- } else {
- searchDefinitions = null;
- unionSearchDefinition = null;
- }
- if (clusters != null) {
- setMasterClusters(clusters);
- } else {
- masterClusters = null;
- }
- }
+ private static Map<String, List<String>> toClusters(QrSearchersConfig config) {
+ if (config == null) return new HashMap<>();
- private void setMasterClusters(QrSearchersConfig config) {
- masterClusters = new HashMap<>();
+ Map<String, List<String>> clusters = new HashMap<>();
for (int i = 0; i < config.searchcluster().size(); ++i) {
List<String> docTypes = new ArrayList<>();
String clusterName = config.searchcluster(i).name();
for (int j = 0; j < config.searchcluster(i).searchdef().size(); ++j) {
docTypes.add(config.searchcluster(i).searchdef(j));
}
- masterClusters.put(clusterName, docTypes);
+ clusters.put(clusterName, docTypes);
}
+ return clusters;
}
@SuppressWarnings("deprecation")
- private void setDefinitions(IndexInfoConfig c) {
- searchDefinitions = new HashMap<>();
- unionSearchDefinition = new SearchDefinition(IndexFacts.unionName);
+ private static Map<String, SearchDefinition> toSearchDefinitions(IndexInfoConfig c) {
+ Map<String, SearchDefinition> searchDefinitions = new HashMap<>();
for (Iterator<IndexInfoConfig.Indexinfo> i = c.indexinfo().iterator(); i.hasNext();) {
IndexInfoConfig.Indexinfo info = i.next();
-
SearchDefinition sd = new SearchDefinition(info.name());
-
for (Iterator<IndexInfoConfig.Indexinfo.Command> j = info.command().iterator(); j.hasNext();) {
IndexInfoConfig.Indexinfo.Command command = j.next();
sd.addCommand(command.indexname(),command.command());
- unionSearchDefinition.addCommand(command.indexname(),command.command());
}
-
sd.fillMatchGroups();
searchDefinitions.put(info.name(), sd);
}
- unionSearchDefinition.fillMatchGroups();
for (IndexInfoConfig.Indexinfo info : c.indexinfo()) {
-
SearchDefinition sd = searchDefinitions.get(info.name());
-
for (IndexInfoConfig.Indexinfo.Alias alias : info.alias()) {
String aliasString = alias.alias();
String indexString = alias.indexname();
sd.addAlias(aliasString, indexString);
- try {
- unionSearchDefinition.addAlias(aliasString, indexString);
- } catch (RuntimeException e) {
- log.log(LogLevel.WARNING,
- "Ignored the alias \""
- + aliasString
- + "\" for \""
- + indexString
- + "\" in the union of all search definitions,"
- + " source has to be explicitly set to \""
- + sd.getName()
- + "\" for that alias to work.", e);
- }
}
}
+ return searchDefinitions;
}
- public Map<String, List<String>> getMasterClusters() {
- return masterClusters;
- }
+ @SuppressWarnings("deprecation")
+ private SearchDefinition unionOf(Collection<SearchDefinition> searchDefinitions) {
+ SearchDefinition union = new SearchDefinition(IndexFacts.unionName);
+
+ for (SearchDefinition sd : searchDefinitions) {
+ for (Index index : sd.indices().values()) {
+ union.getOrCreateIndex(index.getName());
+ for (String command : index.allCommands())
+ union.addCommand(index.getName(), command);
+ for (String alias : index.aliases())
+ union.addAlias(alias, index.getName());
+ }
- public Map<String, SearchDefinition> getSearchDefinitions() {
- return searchDefinitions;
+ }
+ union.fillMatchGroups();
+ return union;
}
- public SearchDefinition getUnionSearchDefinition() {
- return unionSearchDefinition;
- }
+ public Map<String, List<String>> getMasterClusters() { return masterClusters; }
+
+ public Map<String, SearchDefinition> getSearchDefinitions() { return searchDefinitions; }
+
+ // TODO: Deprecate on Vespa 7 and make package scope on Vespa 8
+ public SearchDefinition getUnionSearchDefinition() { return unionSearchDefinition; }
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/Pong.java b/container-search/src/main/java/com/yahoo/prelude/Pong.java
index 017fceb2942..de2a1a4d8fb 100644
--- a/container-search/src/main/java/com/yahoo/prelude/Pong.java
+++ b/container-search/src/main/java/com/yahoo/prelude/Pong.java
@@ -53,7 +53,8 @@ public class Pong {
*
* @deprecated do not use
*/
- @Deprecated
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public Optional<PongPacket> getPongPacket() { return pongPacket; }
/** Returns the number of active documents in the backend responding in this Pong, if available */
diff --git a/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java b/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java
index 47becde7b19..aa76bd5912a 100644
--- a/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java
+++ b/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java
@@ -22,10 +22,7 @@ public class SearchDefinition {
/** A map of all indices in this search definition, indexed by name */
private Map<String, Index> indices = new HashMap<>();
- /*
- * A map of all indices in this search definition, indexed by lower cased
- * name.
- */
+ /* A map of all indices in this search definition, indexed by lower cased name. */
private Map<String, Index> lowerCase = new HashMap<>();
private String defaultPosition;
@@ -49,29 +46,23 @@ public class SearchDefinition {
}
public void addAlias(String alias, String indexName) {
- Index old;
-
- if ((old = indices.get(alias)) != null) {
- if (old.getName().equals(indexName)) {
- return;
- } else {
- throw new IllegalArgumentException("Tried adding the alias \""
- + alias + "\" for the index name \"" + indexName
- + "\" when the name \"" + alias
- + "\" already maps to \"" + old.getName() + "\".");
- }
+ Index old = indices.get(alias);
+ if (old != null) {
+ if (old.getName().equals(indexName)) return;
+ throw new IllegalArgumentException("Tried adding the alias '" + alias + "' for the index name '" +
+ indexName + "' when the name '" + alias +
+ "' already maps to '" + old.getName() + "'");
}
Index index = indices.get(indexName);
- if (index == null) {
- throw new IllegalArgumentException("Failed adding alias \"" + alias
- + "\" for the index name \"" + indexName
- + "\" as there is no index with that name available.");
- }
+ if (index == null)
+ throw new IllegalArgumentException("Failed adding alias '" + alias + "' for the index name '" + indexName +
+ "' as there is no index with that name available.");
indices.put(alias, index);
+ index.addAlias(alias);
+
String lca = toLowerCase(alias);
- if (lowerCase.get(lca) == null) {
+ if (lowerCase.get(lca) == null)
lowerCase.put(lca, index);
- }
}
public Index getIndex(String name) {
@@ -120,6 +111,4 @@ public class SearchDefinition {
}
}
-
-
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
index 0d25e71dd76..28d426cec06 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
@@ -321,7 +321,7 @@ public class FastHit extends Hit {
*
* @deprecated do not use
*/
- @Deprecated
+ @Deprecated // OK
@Override
@SuppressWarnings("deprecation")
public void changeFieldKey(String oldKey, String newKey) {
@@ -358,7 +358,8 @@ public class FastHit extends Hit {
}
/** @deprecated do not use */
- @Deprecated // TODO: Make private on Vespa 7
+ // TODO: Make private on Vespa 7
+ @Deprecated // OK
public static String asHexString(GlobalId gid) {
return asHexString(new StringBuilder(), gid).toString();
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java b/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java
index 9d852c8822d..f9faf242350 100644
--- a/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java
+++ b/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java
@@ -7,7 +7,8 @@ package com.yahoo.prelude.logging;
* @author Steinar Knutsen
* @deprecated do not use
*/
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class AccessLogEntry extends com.yahoo.container.logging.AccessLogEntry {
public AccessLogEntry() {
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java
index 41100dd0b3e..f6f96ae215c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java
@@ -10,7 +10,7 @@ import static com.yahoo.prelude.query.parser.Token.Kind.NUMBER;
/**
* Parser for queries of type advanced.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
* @deprecated since 5.11, YQL+ should be used for formal queries
*/
@Deprecated // OK DO NOT REMOVE (we'll keep this around longer)
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java
index 96e9fb30c24..ff603a64725 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java
@@ -26,10 +26,11 @@ import java.util.*;
* @author Steinar Knutsen
* @deprecated do not use
*/
+// TODO: Remove on Vespa 7 (not necessary any more)
@After({PhaseNames.RAW_QUERY, PHRASE_REPLACEMENT})
@Before(PhaseNames.TRANSFORMED_QUERY)
@Provides(IndexCombinatorSearcher.MIXED_RECALL_REWRITE)
-@Deprecated // TODO: Remove on Vespa 7 (not necessary any more)
+@Deprecated // OK
public class IndexCombinatorSearcher extends Searcher {
public static final String MIXED_RECALL_REWRITE = "MixedRecallRewrite";
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
index 2f9e81c1607..bc3c6665ae2 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
@@ -30,7 +30,8 @@ import java.util.Set;
* @deprecated use {@link com.yahoo.search.searchchain.testutil.DocumentSourceSearcher}
*/
@SuppressWarnings({"rawtypes"})
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class DocumentSourceSearcher extends Searcher {
// as for the SuppressWarnings annotation above, we are inside
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
index 32efcde6feb..4edb907d337 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
@@ -14,7 +14,8 @@ import com.yahoo.search.searchchain.Execution;
* @author Steinar Knutsen
* @deprecated do not use
*/
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class QuerySnapshotSearcher extends Searcher {
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
index 558521a7a8d..fd155354d1c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
@@ -13,7 +13,8 @@ import com.yahoo.search.searchchain.Execution;
* @author Steinar Knutsen
* @deprecated do not use
*/
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class QueryValidatingSearcher extends Searcher {
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/Context.java b/container-search/src/main/java/com/yahoo/prelude/templates/Context.java
index 7989f35e77b..7662ca832f9 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/Context.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/Context.java
@@ -12,7 +12,8 @@ import com.yahoo.text.XML;
* @deprecated use a Renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public abstract class Context {
private boolean xmlEscape = true;
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java
index e8e7f6f2f93..4d6406fe00d 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/DefaultTemplateSet.java
@@ -34,7 +34,8 @@ import java.util.stream.Collectors;
* @deprecated use JsonRenderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public class DefaultTemplateSet extends UserTemplate<XMLWriter> {
private static final Utf8String RESULT = new Utf8String("result");
@@ -196,7 +197,6 @@ public class DefaultTemplateSet extends UserTemplate<XMLWriter> {
}
}
-
/**
* Renders a hit group.
*/
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java b/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java
index dab80580f61..1f724aba112 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java
@@ -16,7 +16,8 @@ import java.util.Set;
* @deprecated use a Renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public class FormattingOptions {
public static final String DEFAULT_TYPE_ATTRIBUTE_NAME = "type";
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/GenericTemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/GenericTemplateSet.java
index 8103f4fa58c..95875d0dd1f 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/GenericTemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/GenericTemplateSet.java
@@ -14,7 +14,8 @@ import java.util.Properties;
*
* @deprecated use a renderer instead
*/
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public class GenericTemplateSet {
public static final String DEFAULT_MIMETYPE = "text/xml";
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java b/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java
index 14b05f5e2a6..5ef28d6f6c6 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java
@@ -6,7 +6,6 @@ import com.yahoo.prelude.hitfield.JSONString;
import com.yahoo.prelude.hitfield.XMLString;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.StructuredData;
-import com.yahoo.search.result.FeatureData;
import com.yahoo.text.XML;
import java.util.Collection;
@@ -20,7 +19,8 @@ import java.util.Set;
* @deprecated use a Renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public class HitContext extends Context {
private final Hit hit;
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/LogExceptionUserTemplateDelegator.java b/container-search/src/main/java/com/yahoo/prelude/templates/LogExceptionUserTemplateDelegator.java
index f9ad3ebf86e..7696790897e 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/LogExceptionUserTemplateDelegator.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/LogExceptionUserTemplateDelegator.java
@@ -16,7 +16,8 @@ import java.util.logging.Logger;
* @deprecated use a renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public class LogExceptionUserTemplateDelegator<T extends Writer> extends UserTemplate<T> {
private static Logger log = Logger.getLogger(LogExceptionUserTemplateDelegator.class.getName());
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java b/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java
index 84d97b71f60..c08c9701741 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java
@@ -11,7 +11,8 @@ import java.util.Map;
* @deprecated use a Renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public class MapContext extends Context {
private Map<String, Object> map = new LinkedHashMap<>();
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java
index 83118ec66ad..cac06011679 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java
@@ -17,7 +17,8 @@ import java.io.Writer;
* @deprecated use a Renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class PageTemplateSet extends TiledTemplateSet {
public PageTemplateSet() {
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java b/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java
index 8439dd105a8..467cd615ebd 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java
@@ -24,7 +24,8 @@ import java.util.Iterator;
* @deprecated do not use
*/
@SuppressWarnings({ "rawtypes", "deprecation", "unchecked" })
-@Deprecated // TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
+// TODO: Remove on Vespa 7
public final class SearchRendererAdaptor extends Renderer {
private final LogExceptionUserTemplateDelegator templates;
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/Template.java b/container-search/src/main/java/com/yahoo/prelude/templates/Template.java
index 3d00be9d05b..761eb1db562 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/Template.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/Template.java
@@ -13,7 +13,8 @@ import java.io.Writer;
* @deprecated use a Renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
+// TODO: Remove on Vespa 7
public abstract class Template<T extends Writer> {
/**
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/TemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/TemplateSet.java
index 98c7af6b9ce..65a5b4cacfd 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/TemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/TemplateSet.java
@@ -21,7 +21,8 @@ import java.io.Writer;
* @deprecated use a renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
+// TODO: Remove on Vespa 7
public class TemplateSet<T extends Writer> extends UserTemplate<T> {
private static final String queryContextTemplateName = "queryContext";
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java
index 91bc33e3e2a..115e9cd44a1 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java
@@ -73,7 +73,8 @@ import java.util.stream.Collectors;
* @deprecated use a Renderer instead
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class TiledTemplateSet extends DefaultTemplateSet {
private FormattingOptions hitOptionsForProvider;
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java b/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java
index ac1583b0577..bcdf3311c1f 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/UserTemplate.java
@@ -24,7 +24,8 @@ import java.util.logging.Logger;
* @author Steinar Knutsen
*/
@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
+// TODO: Remove on Vespa 7
public abstract class UserTemplate<T extends Writer> extends GenericTemplateSet {
// &amp;
diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java
index 53435941e26..1fd81e506bd 100644
--- a/container-search/src/main/java/com/yahoo/search/Query.java
+++ b/container-search/src/main/java/com/yahoo/search/Query.java
@@ -530,7 +530,8 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
/**
* @deprecated do not use
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public boolean requestHasProperty(String name) {
return httpRequest.hasProperty(name);
}
@@ -644,7 +645,8 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
*
* @deprecated this is ignored
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public void setCompress(boolean ignored) { }
/**
@@ -652,7 +654,8 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
*
* @deprecated this always returns false
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public boolean getCompress() { return false; }
/** Returns a string describing this query */
diff --git a/container-search/src/main/java/com/yahoo/search/Result.java b/container-search/src/main/java/com/yahoo/search/Result.java
index b8df086a92a..e70916369a3 100644
--- a/container-search/src/main/java/com/yahoo/search/Result.java
+++ b/container-search/src/main/java/com/yahoo/search/Result.java
@@ -97,7 +97,7 @@ public final class Result extends com.yahoo.processing.Response implements Clone
totalHitCount += result.getTotalHitCount();
deepHitCount += result.getDeepHitCount();
timeAccountant.merge(result.getElapsedTime());
- boolean create=true;
+ boolean create = true;
if (result.getCoverage(!create) != null || getCoverage(!create) != null)
getCoverage(create).merge(result.getCoverage(create));
}
@@ -228,7 +228,7 @@ public final class Result extends com.yahoo.processing.Response implements Clone
resultClone.hits = hits.clone();
- resultClone.getTemplating().setRenderer(null); // TODO: Kind of wrong
+ resultClone.getTemplating().setRenderer(null); // TODO: Remove on Vespa 7
resultClone.setElapsedTime(new ElapsedTime());
return resultClone;
}
@@ -315,16 +315,8 @@ public final class Result extends com.yahoo.processing.Response implements Clone
* @return the coverage information of this, or null if none and create is false
*/
public Coverage getCoverage(boolean create) {
- if (coverage == null && create) {
- if (hits.getError() == null) {
- // No error here implies full coverage.
- // Don't count this as a result set if there's no data - avoid counting empty results made
- // to simplify code paths
- coverage = new Coverage(0L, 0, true, (hits().size()==0 ? 0 : 1));
- } else {
- coverage = new Coverage(0L, 0, false);
- }
- }
+ if (coverage == null && create)
+ coverage = new Coverage(0L, 0, 0, (hits().size() == 0 ? 0 : 1));
return coverage;
}
@@ -350,7 +342,10 @@ public final class Result extends com.yahoo.processing.Response implements Clone
* result rendering.
*
* @return helper object for result rendering
+ * @deprecated use renderers
*/
+ // TODO: Remove on Vespa 7
+ @Deprecated// OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
public Templating getTemplating() {
return templating;
}
diff --git a/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java b/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java
index 3896e817429..4878691742c 100644
--- a/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java
+++ b/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java
@@ -38,7 +38,8 @@ public class ClusterMonitor<T> {
private final Map<T, BaseNodeMonitor<T>> nodeMonitors = Collections.synchronizedMap(new java.util.LinkedHashMap<>());
/** @deprecated use the constructor with just the first argument instead */
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public ClusterMonitor(NodeManager<T> manager, String ignored) {
this(manager);
}
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPClientSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPClientSearcher.java
index 8abd6deb5f9..1607d108722 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPClientSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPClientSearcher.java
@@ -15,8 +15,10 @@ import com.yahoo.statistics.Statistics;
* the provider and cache configurations to parameters which are passed upwards.
*
* @author bratseth
+ * @deprecated
*/
-@Deprecated
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public abstract class ConfiguredHTTPClientSearcher extends HTTPClientSearcher {
/** Create this from a configuraton */
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPProviderSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPProviderSearcher.java
index 22c2802c9e8..9f99a790df0 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPProviderSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredHTTPProviderSearcher.java
@@ -19,7 +19,8 @@ import java.util.Collections;
* @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a>
* @author bratseth
*/
-@Deprecated
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public abstract class ConfiguredHTTPProviderSearcher extends HTTPProviderSearcher {
/** Create this from a configuraton */
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredSearcherHelper.java b/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredSearcherHelper.java
index f750685d18e..0fa235709f9 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredSearcherHelper.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/ConfiguredSearcherHelper.java
@@ -11,6 +11,7 @@ import com.yahoo.search.federation.ProviderConfig;
*
* @author bratseth
*/
+// TODO: Remove on Vespa 7
class ConfiguredSearcherHelper {
/** No instantiation */
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/Connection.java b/container-search/src/main/java/com/yahoo/search/federation/http/Connection.java
index 0b2711eed1c..4f624a12547 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/Connection.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/Connection.java
@@ -8,7 +8,10 @@ package com.yahoo.search.federation.http;
* The host and port state is immutable.
*
* @author bratseth
+ * @deprecated
*/
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class Connection {
private String host;
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/GzipDecompressingEntity.java b/container-search/src/main/java/com/yahoo/search/federation/http/GzipDecompressingEntity.java
index c686265f65d..0407ddeca1b 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/GzipDecompressingEntity.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/GzipDecompressingEntity.java
@@ -15,8 +15,11 @@ import java.util.zip.GZIPInputStream;
/**
* Used by HTTPSearcher when talking to services returning compressed content.
*
- * @author <a href="mailto:mainak@yahoo-inc.com">Mainak Mandal</a>
+ * @author Mainak Mandal
+ * @deprecated
*/
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class GzipDecompressingEntity extends HttpEntityWrapper {
private static class Resources {
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPClientSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPClientSearcher.java
index dc0b5981e63..ee093adc6fc 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPClientSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPClientSearcher.java
@@ -90,8 +90,10 @@ import java.util.logging.Logger;
* @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a>
* @author bratseth
+ * @deprecated
*/
-@Deprecated
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public abstract class HTTPClientSearcher extends HTTPSearcher {
static final CompoundName REQUEST_META_CARRIER = new CompoundName("com.yahoo.search.federation.http.HTTPClientSearcher_requestMeta");
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPParameters.java b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPParameters.java
index 99dae4e20aa..a7b32678c1a 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPParameters.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPParameters.java
@@ -15,7 +15,10 @@ import com.yahoo.search.federation.ProviderConfig;
* A set of parameters for talking to an http backend
*
* @author bratseth
+ * @deprecated
*/
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public final class HTTPParameters {
public static final String RETRIES = "com.yahoo.search.federation.http.retries";
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPProviderSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPProviderSearcher.java
index d0f76b815dc..c72c2f26a1c 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPProviderSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPProviderSearcher.java
@@ -38,8 +38,10 @@ import java.util.logging.Logger;
*
* @author Arne Bergene Fossaa
* @author bratseth
+ * @deprecated
*/
-@Deprecated
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public abstract class HTTPProviderSearcher extends HTTPSearcher {
private final Counter emptyResults;
@@ -89,7 +91,7 @@ public abstract class HTTPProviderSearcher extends HTTPSearcher {
}
/** @deprecated this method does nothing */
- @Deprecated
+ @Deprecated // OK
protected void configureCache(final QrBinaryCacheConfig cacheConfig,final QrBinaryCacheRegionConfig regionConfig) {
}
@@ -253,7 +255,7 @@ public abstract class HTTPProviderSearcher extends HTTPSearcher {
/**
* @deprecated the cache key is ignored as there is no built-in caching support
*/
- @Deprecated
+ @Deprecated // OK
public abstract Map<String, String> getCacheKey(Query q);
}
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPSearcher.java
index 80e785f0175..edf347bd84e 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/HTTPSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/HTTPSearcher.java
@@ -135,8 +135,10 @@ import java.util.logging.Logger;
* </dl>
*
* @author Arne Bergene Fossaa
+ * @deprecated
*/
-@Deprecated
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public abstract class HTTPSearcher extends ClusterSearcher<Connection> {
protected static final String YCA_HTTP_HEADER = "Yahoo-App-Auth";
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/TimedHttpEntity.java b/container-search/src/main/java/com/yahoo/search/federation/http/TimedHttpEntity.java
index 04108784cdb..03ffe2b8a9c 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/TimedHttpEntity.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/TimedHttpEntity.java
@@ -12,7 +12,10 @@ import org.apache.http.HttpEntity;
* Wrapper for adding timeout to an HttpEntity instance.
*
* @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @deprecated
*/
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class TimedHttpEntity implements HttpEntity {
/**
* The wrapped entity. Never null.
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/TimedStream.java b/container-search/src/main/java/com/yahoo/search/federation/http/TimedStream.java
index 0bef2e97d8c..77a42ee0a34 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/TimedStream.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/TimedStream.java
@@ -8,7 +8,10 @@ import java.io.InputStream;
* A stream which throws a TimeoutException if query timeout has been reached.
*
* @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @deprecated
*/
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class TimedStream extends InputStream {
/**
diff --git a/container-search/src/main/java/com/yahoo/search/federation/http/TimeoutException.java b/container-search/src/main/java/com/yahoo/search/federation/http/TimeoutException.java
index 1b49f220d42..18dd59ec37b 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/http/TimeoutException.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/http/TimeoutException.java
@@ -5,7 +5,10 @@ package com.yahoo.search.federation.http;
* Timeout marker for slow HTTP connections.
*
* @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @deprecated
*/
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class TimeoutException extends RuntimeException {
/**
diff --git a/container-search/src/main/java/com/yahoo/search/federation/vespa/QueryMarshaller.java b/container-search/src/main/java/com/yahoo/search/federation/vespa/QueryMarshaller.java
index 2bfec008761..3a0db9b76de 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/vespa/QueryMarshaller.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/vespa/QueryMarshaller.java
@@ -11,7 +11,10 @@ import com.yahoo.prelude.query.*;
*
* @author Steinar Knutsen
* @author Rong-En Fan
+ * @deprecated use YQL
*/
+// TODO: Remove on Vespa 7
+@Deprecated // OK
public class QueryMarshaller {
private boolean atRoot = true;
diff --git a/container-search/src/main/java/com/yahoo/search/federation/vespa/ResultBuilder.java b/container-search/src/main/java/com/yahoo/search/federation/vespa/ResultBuilder.java
index dd20472474d..a6aec30b496 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/vespa/ResultBuilder.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/vespa/ResultBuilder.java
@@ -29,8 +29,10 @@ import static com.yahoo.text.Lowercase.toLowerCase;
* Parse Vespa XML results and create Result instances.
*
* @author Steinar Knutsen
+ * @deprecated
*/
-// Ripe for a rewrite or major refactoring.
+// TODO: Remove on Vespa 7
+@Deprecated // OK
@SuppressWarnings("deprecation")
public class ResultBuilder extends DefaultHandler {
private static final String ERROR = "error";
diff --git a/container-search/src/main/java/com/yahoo/search/federation/vespa/VespaSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/vespa/VespaSearcher.java
index fdbee9c8f11..246732d0970 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/vespa/VespaSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/vespa/VespaSearcher.java
@@ -45,7 +45,9 @@ import edu.umd.cs.findbugs.annotations.Nullable;
*
* @author Arne Bergene Fossaa
* @author Steinar Knutsen
+ * @deprecated
*/
+// TODO: Remove on Vespa 7
@Deprecated
@Provides("Vespa")
@After("*")
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java
index f1f1e2e3b55..83eca89dffa 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingRequest.java
@@ -128,7 +128,8 @@ public class GroupingRequest {
* @return this, to allow chaining.
* @deprecated this is a noop
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public GroupingRequest setResultGroup(RootGroup group) {
return this;
}
@@ -164,7 +165,8 @@ public class GroupingRequest {
* @deprecated use query.getSelect().getGrouping()
*/
@SuppressWarnings({ "unchecked" })
- @Deprecated
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public static List<GroupingRequest> getRequests(Query query) {
return query.getSelect().getGrouping();
}
diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
index c6d877c006a..2fd041002cf 100644
--- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
+++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
@@ -127,20 +127,19 @@ public class SearchHandler extends LoggingRequestHandler {
}
@Inject
- public SearchHandler(
- final ChainsConfig chainsConfig,
- final IndexInfoConfig indexInfo,
- final QrSearchersConfig clusters,
- final SpecialtokensConfig specialtokens,
- final Statistics statistics,
- final Linguistics linguistics,
- final Metric metric,
- final ComponentRegistry<Renderer> renderers,
- final Executor executor,
- final AccessLog accessLog,
- final QueryProfilesConfig queryProfileConfig,
- final ComponentRegistry<Searcher> searchers,
- final ContainerHttpConfig containerHttpConfig) {
+ public SearchHandler(ChainsConfig chainsConfig,
+ IndexInfoConfig indexInfo,
+ QrSearchersConfig clusters,
+ SpecialtokensConfig specialtokens,
+ Statistics statistics,
+ Linguistics linguistics,
+ Metric metric,
+ ComponentRegistry<Renderer> renderers,
+ Executor executor,
+ AccessLog accessLog,
+ QueryProfilesConfig queryProfileConfig,
+ ComponentRegistry<Searcher> searchers,
+ ContainerHttpConfig containerHttpConfig) {
super(executor, accessLog, metric, true);
log.log(LogLevel.DEBUG, "SearchHandler.init " + System.identityHashCode(this));
searchChainRegistry = new SearchChainRegistry(searchers);
@@ -167,7 +166,7 @@ public class SearchHandler extends LoggingRequestHandler {
/** @deprecated use the constructor with ContainerHttpConfig */
// TODO: Remove on Vespa 7
- @Deprecated
+ @Deprecated // OK
public SearchHandler(
final ChainsConfig chainsConfig,
final IndexInfoConfig indexInfo,
@@ -187,7 +186,7 @@ public class SearchHandler extends LoggingRequestHandler {
/** @deprecated use the constructor without deprecated parameters */
// TODO: Remove on Vespa 7
- @Deprecated
+ @Deprecated // OK
public SearchHandler(
final ChainsConfig chainsConfig,
final IndexInfoConfig indexInfo,
@@ -264,7 +263,7 @@ public class SearchHandler extends LoggingRequestHandler {
Result result = new Result(query, errorMessage);
Renderer renderer = getRendererCopy(ComponentSpecification.fromString(request.getProperty("format")));
- result.getTemplating().setRenderer(renderer); // Pre-Vespa 6 Result.getEncoding() expects this TODO: Remove
+ result.getTemplating().setRenderer(renderer); // Pre-Vespa 6 Result.getEncoding() expects this TODO: Remove opn Vespa 7
return new HttpSearchResponse(getHttpResponseStatus(request, result), result, query, renderer);
}
@@ -323,11 +322,11 @@ public class SearchHandler extends LoggingRequestHandler {
}
Renderer renderer;
- if (result.getTemplating().usesDefaultTemplate()) {
+ if (result.getTemplating().usesDefaultTemplate()) { // TODO: Remove on Vespa 7
renderer = toRendererCopy(query.getPresentation().getRenderer());
- result.getTemplating().setRenderer(renderer); // pre-Vespa 6 Result.getEncoding() expects this to be set. TODO: Remove
+ result.getTemplating().setRenderer(renderer); // pre-Vespa 6 Result.getEncoding() expects this to be set.
}
- else { // somebody explicitly assigned a old style template
+ else { // somebody explicitly assigned a old style template // TODO: Remove on Vespa 7
renderer = perRenderingCopy(result.getTemplating().getRenderer());
}
@@ -391,7 +390,7 @@ public class SearchHandler extends LoggingRequestHandler {
}
Result result = execution.search(query);
- if (result.getTemplating() == null)
+ if (result.getTemplating() == null) // TODO: Remove on Vespa 7
result.getTemplating().setRenderer(renderer);
ensureQuerySet(result, query);
@@ -412,11 +411,8 @@ public class SearchHandler extends LoggingRequestHandler {
/**
* For internal use only
- *
- * @deprecated remove on Vespa 7
*/
- @Deprecated
- public Renderer<Result> getRendererCopy(ComponentSpecification spec) { // TODO: Deprecate this
+ public Renderer<Result> getRendererCopy(ComponentSpecification spec) {
Renderer<Result> renderer = rendererRegistry.getRenderer(spec);
return perRenderingCopy(renderer);
}
diff --git a/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplate.java b/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplate.java
index 077c4507ad8..dc390c773d8 100644
--- a/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplate.java
+++ b/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplate.java
@@ -12,7 +12,7 @@ import java.util.Collections;
import java.util.Set;
/**
- * A page template represents a particular way to organize a return page. It is a recursive structure of
+ * A page template represents a particular way to organize a result page. It is a recursive structure of
* page template elements.
*
* @author bratseth
diff --git a/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplateSearcher.java b/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplateSearcher.java
index 22fd78d6faa..0ec04bf99de 100644
--- a/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplateSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplateSearcher.java
@@ -46,7 +46,7 @@ import java.util.*;
* </ul>
*
* <p>
- * The set of page templates chosen for the query specifies a list of sources to be queries (the page template sources).
+ * The set of page templates chosen for the query specifies a list of sources to be queried (the page template sources).
* In addition, the query may contain
* <ul>
* <li>a set of sources set explicitly in the Request, a query property or a searcher (the query model sources)
diff --git a/container-search/src/main/java/com/yahoo/search/pagetemplates/model/PageElement.java b/container-search/src/main/java/com/yahoo/search/pagetemplates/model/PageElement.java
index 7b93fddef33..90239fdeb8d 100644
--- a/container-search/src/main/java/com/yahoo/search/pagetemplates/model/PageElement.java
+++ b/container-search/src/main/java/com/yahoo/search/pagetemplates/model/PageElement.java
@@ -11,6 +11,6 @@ import com.yahoo.component.provider.Freezable;
public interface PageElement extends Freezable {
/** Accepts a visitor to this structure */
- public void accept(PageTemplateVisitor visitor);
+ void accept(PageTemplateVisitor visitor);
}
diff --git a/container-search/src/main/java/com/yahoo/search/pagetemplates/result/PageTemplatesXmlRenderer.java b/container-search/src/main/java/com/yahoo/search/pagetemplates/result/PageTemplatesXmlRenderer.java
new file mode 100644
index 00000000000..b7d7188e77e
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/search/pagetemplates/result/PageTemplatesXmlRenderer.java
@@ -0,0 +1,334 @@
+package com.yahoo.search.pagetemplates.result;
+
+import com.yahoo.io.ByteWriter;
+import com.yahoo.prelude.fastsearch.GroupingListHit;
+import com.yahoo.prelude.hitfield.HitField;
+import com.yahoo.prelude.hitfield.JSONString;
+import com.yahoo.prelude.hitfield.XMLString;
+import com.yahoo.processing.rendering.AsynchronousSectionedRenderer;
+import com.yahoo.processing.response.Data;
+import com.yahoo.processing.response.DataList;
+import com.yahoo.search.Query;
+import com.yahoo.search.Result;
+import com.yahoo.search.pagetemplates.model.Renderer;
+import com.yahoo.search.pagetemplates.model.Source;
+import com.yahoo.search.query.context.QueryContext;
+import com.yahoo.search.result.Coverage;
+import com.yahoo.search.result.DefaultErrorHit;
+import com.yahoo.search.result.ErrorHit;
+import com.yahoo.search.result.ErrorMessage;
+import com.yahoo.search.result.Hit;
+import com.yahoo.search.result.HitGroup;
+import com.yahoo.search.result.StructuredData;
+import com.yahoo.text.Utf8String;
+import com.yahoo.text.XML;
+import com.yahoo.text.XMLWriter;
+import com.yahoo.yolean.trace.TraceNode;
+
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.stream.Collectors;
+
+public class PageTemplatesXmlRenderer extends AsynchronousSectionedRenderer<Result> {
+
+ public static final String DEFAULT_MIMETYPE = "text/xml";
+ public static final String DEFAULT_ENCODING = "utf-8";
+
+ private static final Utf8String GROUP = new Utf8String("group");
+ private static final Utf8String HIT = new Utf8String("hit");
+ private static final Utf8String ERROR = new Utf8String("error");
+ private static final Utf8String CODE = new Utf8String("code");
+ private static final Utf8String COVERAGE_DOCS = new Utf8String("coverage-docs");
+ private static final Utf8String COVERAGE_NODES = new Utf8String("coverage-nodes");
+ private static final Utf8String COVERAGE_FULL = new Utf8String("coverage-full");
+ private static final Utf8String COVERAGE = new Utf8String("coverage");
+ private static final Utf8String RESULTS_FULL = new Utf8String("results-full");
+ private static final Utf8String RESULTS = new Utf8String("results");
+ private static final Utf8String TYPE = new Utf8String("type");
+ private static final Utf8String RELEVANCE = new Utf8String("relevance");
+ private static final Utf8String SOURCE = new Utf8String("source");
+
+ private XMLWriter writer;
+
+ public PageTemplatesXmlRenderer() {
+ this(null);
+ }
+
+ /**
+ * Creates a json renderer using a custom executor.
+ * Using a custom executor is useful for tests to avoid creating new threads for each renderer registry.
+ */
+ public PageTemplatesXmlRenderer(Executor executor) {
+ super(executor);
+ }
+
+ @Override
+ public void init() {
+ super.init();
+ writer = null;
+ }
+
+ @Override
+ public String getEncoding() {
+ if (getResult() == null
+ || getResult().getQuery() == null
+ || getResult().getQuery().getModel().getEncoding() == null) {
+ return DEFAULT_ENCODING;
+ } else {
+ return getResult().getQuery().getModel().getEncoding();
+ }
+ }
+
+ @Override
+ public String getMimeType() {
+ return DEFAULT_MIMETYPE;
+ }
+
+ private XMLWriter wrapWriter(Writer writer) {
+ return XMLWriter.from(writer, 10, -1);
+ }
+
+ private void header(XMLWriter writer, Result result) {
+ writer.xmlHeader(getRequestedEncoding(result.getQuery()));
+ writer.openTag("page").attribute("version", "1.0")
+ .attribute("layout", result.hits().getField("layout"));
+ renderCoverageAttributes(result.getCoverage(false), writer);
+ writer.closeStartTag();
+ renderSectionContent(writer, result.hits());
+ }
+
+ private static void renderCoverageAttributes(Coverage coverage, XMLWriter writer) {
+ if (coverage == null) return;
+ writer.attribute(COVERAGE_DOCS,coverage.getDocs());
+ writer.attribute(COVERAGE_NODES,coverage.getNodes());
+ writer.attribute(COVERAGE_FULL,coverage.getFull());
+ writer.attribute(COVERAGE,coverage.getResultPercentage());
+ writer.attribute(RESULTS_FULL,coverage.getFullResultSets());
+ writer.attribute(RESULTS,coverage.getResultSets());
+ }
+
+ public void error(XMLWriter writer, Result result) {
+ ErrorMessage error = result.hits().getError();
+ writer.openTag(ERROR).attribute(CODE,error.getCode()).content(error.getMessage(),false).closeTag();
+ }
+
+ private void queryContext(XMLWriter writer, Query owner) {
+ if (owner.getTraceLevel()!=0) {
+ XMLWriter xmlWriter=XMLWriter.from(writer);
+ xmlWriter.openTag("meta").attribute("type", QueryContext.ID);
+ TraceNode traceRoot = owner.getModel().getExecution().trace().traceNode().root();
+ traceRoot.accept(new com.yahoo.search.rendering.DefaultRenderer.RenderingVisitor(xmlWriter, owner.getStartTime()));
+ xmlWriter.closeTag();
+ }
+ }
+
+ private void renderSingularHit(XMLWriter writer, Hit hit) {
+ if ( ! hit.isMeta() && ! writer.isIn("content"))
+ writer.openTag("content");
+
+ writer.openTag(HIT);
+ renderHitAttributes(hit,writer);
+ writer.closeStartTag();
+ renderField(writer, "id", hit.getId());
+ hit.forEachField((name, value) -> renderField(writer, name, value));
+ writer.closeTag();
+ }
+
+ /** Writes a hit's default attributes like 'type', 'source', 'relevance'. */
+ private void renderHitAttributes(Hit hit, XMLWriter writer) {
+ writer.attribute(TYPE, hit.types().stream().collect(Collectors.joining(" ")));
+ if (hit.getRelevance() != null)
+ writer.attribute(RELEVANCE, hit.getRelevance().toString());
+ writer.attribute(SOURCE, hit.getSource());
+ }
+
+ private void renderField(XMLWriter writer, String name, Object value) {
+ writer.openTag(name);
+ renderFieldContent(writer, value);
+ writer.closeTag();
+ }
+
+ private void renderFieldContent(XMLWriter writer, Object value) {
+ writer.escapedContent(asXML(value), false);
+ }
+
+ private String asXML(Object value) {
+ if (value == null)
+ return "(null)";
+ else if (value instanceof HitField)
+ return ((HitField)value).quotedContent(false);
+ else if (value instanceof StructuredData || value instanceof XMLString || value instanceof JSONString)
+ return value.toString();
+ else
+ return XML.xmlEscape(value.toString(), false, '\u001f');
+ }
+
+ private void renderHitAttributes(XMLWriter writer, Hit hit) {
+ writer.attribute(TYPE, hit.types().stream().collect(Collectors.joining(" ")));
+ if (hit.getRelevance() != null)
+ writer.attribute(RELEVANCE, hit.getRelevance().toString());
+ writer.attribute(SOURCE, hit.getSource());
+ }
+
+ private void renderHitGroup(XMLWriter writer, HitGroup hit) {
+ if (hit.types().contains("section")) {
+
+ renderSection(writer, hit); // Renders /result/section
+ }
+ else if (hit.types().contains("meta")) {
+ writer.openTag("meta"); // renders /result/meta
+ writer.closeStartTag();
+ }
+ else {
+ renderGroup(writer, hit);
+ }
+ }
+
+ private void renderGroup(XMLWriter writer, HitGroup hit) {
+ writer.openTag(GROUP);
+ renderHitAttributes(writer, hit);
+ writer.closeStartTag();
+ }
+
+ private void renderSection(XMLWriter writer, HitGroup hit) {
+ writer.openTag("section");
+ writer.attribute("id", hit.getDisplayId());
+ writer.attribute("layout", hit.getField("layout"));
+ writer.attribute("region", hit.getField("region"));
+ writer.attribute("placement", hit.getField("placement")); // deprecated in 5.0
+ writer.closeStartTag();
+ renderSectionContent(writer, hit);
+ }
+
+ private void renderSectionContent(XMLWriter writer, HitGroup hit) {
+ if (hit instanceof SectionHitGroup) { // render additional information
+ SectionHitGroup sectionGroup = (SectionHitGroup)hit;
+ for (Source source : sectionGroup.sources()) {
+ writer.openTag("source").attribute("url", source.getUrl());
+ renderParameters(source.parameters(), writer);
+ writer.closeTag();
+ }
+ for (Renderer renderer : sectionGroup.renderers()) {
+ writer.openTag("renderer").attribute("for", renderer.getRendererFor()).attribute("name", renderer.getName());
+ renderParameters(renderer.parameters(), writer);
+ writer.closeTag();
+ }
+ }
+ }
+
+ private void renderParameters(Map<String,String> parameters, XMLWriter writer) {
+ // Render content
+ for (Map.Entry<String, String> parameter : parameters.entrySet())
+ writer.openTag("parameter").attribute("name", parameter.getKey())
+ .content(parameter.getValue(), false)
+ .closeTag();
+ }
+
+ private boolean simpleRenderHit(XMLWriter writer, Hit hit) {
+ if (hit instanceof DefaultErrorHit) {
+ return simpleRenderDefaultErrorHit(writer, (DefaultErrorHit) hit);
+ } else if (hit instanceof GroupingListHit) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static boolean simpleRenderDefaultErrorHit(XMLWriter writer, ErrorHit defaultErrorHit) {
+ writer.openTag("errordetails");
+ for (Iterator i = defaultErrorHit.errorIterator(); i.hasNext();) {
+ ErrorMessage error = (ErrorMessage) i.next();
+ renderMessageDefaultErrorHit(writer, error);
+ }
+ writer.closeTag();
+ return true;
+ }
+
+ public static void renderMessageDefaultErrorHit(XMLWriter writer, ErrorMessage error) {
+ writer.openTag("error");
+ writer.attribute("source", error.getSource());
+ writer.attribute("error", error.getMessage());
+ writer.attribute("code", Integer.toString(error.getCode()));
+ writer.content(error.getDetailedMessage(), false);
+ if (error.getCause()!=null) {
+ writer.openTag("cause");
+ writer.content("\n", true);
+ StringWriter stackTrace=new StringWriter();
+ error.getCause().printStackTrace(new PrintWriter(stackTrace));
+ writer.content(stackTrace.toString(), true);
+ writer.closeTag();
+ }
+ writer.closeTag();
+ }
+
+ private Result getResult() {
+ try {
+ return (Result) getResponse();
+ } catch (ClassCastException e) {
+ throw new IllegalArgumentException("PageTemplatesXmlRenderer attempted used outside a search context, got a " +
+ getResponse().getClass().getName());
+ }
+ }
+
+ @Override
+ public void beginResponse(OutputStream stream) {
+ Charset cs = Charset.forName(getRequestedEncoding(getResult().getQuery()));
+ CharsetEncoder encoder = cs.newEncoder();
+ writer = wrapWriter(new ByteWriter(stream, encoder));
+
+ header(writer, getResult());
+ if (getResult().hits().getError() != null || getResult().hits().getQuery().errors().size() > 0)
+ error(writer, getResult());
+
+ if (getResult().getContext(false) != null)
+ queryContext(writer, getResult().getQuery());
+ }
+
+ /** Returns the encoding of the query, or the encoding given by the template if none is set */
+ public final String getRequestedEncoding(Query query) {
+ String encoding = query.getModel().getEncoding();
+ if (encoding != null) return encoding;
+ return getEncoding();
+ }
+
+ @Override
+ public void beginList(DataList<?> list) {
+ if (getRecursionLevel() == 1) return;
+
+ HitGroup hit = (HitGroup) list;
+ boolean renderedSimple = simpleRenderHit(writer, hit);
+ if (renderedSimple) return;
+
+ renderHitGroup(writer, hit);
+ }
+
+ @Override
+ public void data(Data data) {
+ Hit hit = (Hit) data;
+ boolean renderedSimple = simpleRenderHit(writer, hit);
+ if ( ! renderedSimple)
+ renderSingularHit(writer, hit);
+ }
+
+ @Override
+ public void endList(DataList<?> list) {
+ if (writer.isIn("content"))
+ writer.closeTag();
+ if (getRecursionLevel() > 1)
+ writer.closeTag();
+ }
+
+ @Override
+ public void endResponse() {
+ writer.closeTag();
+ writer.close();
+ }
+
+} \ No newline at end of file
diff --git a/container-search/src/main/java/com/yahoo/search/query/Model.java b/container-search/src/main/java/com/yahoo/search/query/Model.java
index 95cd3849cf6..4baa651fa01 100644
--- a/container-search/src/main/java/com/yahoo/search/query/Model.java
+++ b/container-search/src/main/java/com/yahoo/search/query/Model.java
@@ -99,7 +99,8 @@ public class Model implements Cloneable {
*
* @deprecated do not use; language can now be assigned later and for parts of the query tree, making this quite useless
*/
- @Deprecated
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public void traceLanguage() {
if (getParent().getTraceLevel() < 2) return;
if (language != null) {
@@ -536,7 +537,8 @@ public class Model implements Cloneable {
* @param next string representation of header value
* @deprecated not used, ytrace has been discontinued
*/
- @Deprecated
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public void setYTraceHeaderToNext(String next) { }
/**
@@ -546,7 +548,8 @@ public class Model implements Cloneable {
*
* @deprecated not used, ytrace has been discontinued
*/
- @Deprecated
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public String getYTraceHeaderToNext() {
return null;
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/Presentation.java b/container-search/src/main/java/com/yahoo/search/query/Presentation.java
index d9b554e3270..ae179a2ba07 100644
--- a/container-search/src/main/java/com/yahoo/search/query/Presentation.java
+++ b/container-search/src/main/java/com/yahoo/search/query/Presentation.java
@@ -97,12 +97,12 @@ public class Presentation implements Cloneable {
public void setBolding(boolean bolding) { this.bolding = bolding; }
/** @deprecated coverage information is always returned */
- @Deprecated
+ @Deprecated // OK
// TODO: Remove on Vespa 7
public boolean getReportCoverage() { return true; }
/** @deprecated coverage information is always returned */
- @Deprecated
+ @Deprecated // OK
// TODO: Remove on Vespa 7
public void setReportCoverage(boolean ignored) { }
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 559a7279f83..55855624691 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
@@ -29,11 +29,9 @@ import java.util.Map;
*/
public class QueryProperties extends Properties {
- /**
- * TODO: Remove on Vespa 7
- * @deprecated use Query.nativeProperties
- */
- @Deprecated
+ /** @deprecated use Query.nativeProperties */
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public static final CompoundName[] PER_SOURCE_QUERY_PROPERTIES =
Query.nativeProperties.toArray(new CompoundName[] {});
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/QueryCombinator.java b/container-search/src/main/java/com/yahoo/search/querytransform/QueryCombinator.java
index 62560d2e00a..67cb291a760 100644
--- a/container-search/src/main/java/com/yahoo/search/querytransform/QueryCombinator.java
+++ b/container-search/src/main/java/com/yahoo/search/querytransform/QueryCombinator.java
@@ -38,7 +38,7 @@ import java.util.Set;
* @deprecated use YQL
*/
// TODO: Remove on Vespa 7
-@Deprecated
+@Deprecated // OK
public class QueryCombinator extends Searcher {
private static final String QUERYPREFIX = "query.";
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java
index aa825149bb7..3562a1a9572 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/DefaultRenderer.java
@@ -1,16 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.rendering;
-import com.fasterxml.jackson.core.JsonFactory;
import com.yahoo.concurrent.CopyOnWriteHashMap;
import com.yahoo.io.ByteWriter;
import com.yahoo.net.URI;
-import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.fastsearch.GroupingListHit;
import com.yahoo.prelude.hitfield.HitField;
import com.yahoo.prelude.hitfield.JSONString;
import com.yahoo.prelude.hitfield.XMLString;
-import com.yahoo.prelude.templates.UserTemplate;
import com.yahoo.processing.rendering.AsynchronousSectionedRenderer;
import com.yahoo.processing.response.Data;
import com.yahoo.processing.response.DataList;
@@ -33,12 +30,9 @@ import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.util.Iterator;
-import java.util.Map;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
-// TODO: Rename to XmlRenderer and make this a deprecated empty subclass.
-
/**
* XML rendering of search results. This is NOT the default (but it once was).
*
@@ -46,7 +40,8 @@ import java.util.stream.Collectors;
* @deprecated use JsonRenderer instead
*/
@SuppressWarnings({ "rawtypes", "deprecation" })
-@Deprecated // TODO: Remove on Vespa 7
+@Deprecated // OK
+// TODO: Rename to XmlRenderer on Vespa 7
public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result> {
public static final String DEFAULT_MIMETYPE = "text/xml";
@@ -85,7 +80,7 @@ public final class DefaultRenderer extends AsynchronousSectionedRenderer<Result>
}
/**
- * Creates a json renderer using a custom executor.
+ * Creates an XML renderer using a custom executor.
* Using a custom executor is useful for tests to avoid creating new threads for each renderer registry.
*/
public DefaultRenderer(Executor executor) {
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java
index 6919f6bd3f8..9a716e4b18b 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/SyncDefaultRenderer.java
@@ -2,18 +2,12 @@
package com.yahoo.search.rendering;
import com.yahoo.concurrent.CopyOnWriteHashMap;
-import com.yahoo.io.ByteWriter;
import com.yahoo.log.LogLevel;
import com.yahoo.net.URI;
-import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.fastsearch.GroupingListHit;
import com.yahoo.prelude.hitfield.HitField;
import com.yahoo.prelude.hitfield.JSONString;
import com.yahoo.prelude.hitfield.XMLString;
-import com.yahoo.prelude.templates.Context;
-import com.yahoo.prelude.templates.DefaultTemplateSet;
-import com.yahoo.prelude.templates.MapContext;
-import com.yahoo.prelude.templates.UserTemplate;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.grouping.result.HitRenderer;
@@ -30,7 +24,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Iterator;
-import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -70,16 +63,12 @@ public final class SyncDefaultRenderer extends Renderer {
//Per instance members, must be created at rendering time, not construction time due to cloning.
- private Context context;
-
- private final DefaultTemplateSet defaultTemplate = new DefaultTemplateSet();
private final CopyOnWriteHashMap<String, Utf8String> fieldNameMap = new CopyOnWriteHashMap<>();
@Override
public void init() {
super.init();
- context = new MapContext();
}
@Override
@@ -107,12 +96,6 @@ public final class SyncDefaultRenderer extends Renderer {
public void render(Writer writer, Result result) throws IOException {
XMLWriter xmlWriter = wrapWriter(writer);
- context.put("context", context);
- context.put("result", result);
- context.setBoldOpenTag(defaultTemplate.getBoldOpenTag());
- context.setBoldCloseTag(defaultTemplate.getBoldCloseTag());
- context.setSeparatorTag(defaultTemplate.getSeparatorTag());
-
try {
header(xmlWriter, result);
} catch (Exception e) {
@@ -138,7 +121,6 @@ public final class SyncDefaultRenderer extends Renderer {
private void header(XMLWriter writer, Result result) throws IOException {
// TODO: move setting this to Result
- context.setUtf8Output("utf-8".equalsIgnoreCase(getRequestedEncoding(result.getQuery())));
writer.xmlHeader(getRequestedEncoding(result.getQuery()));
writer.openTag(RESULT).attribute(TOTAL_HIT_COUNT,String.valueOf(result.getTotalHitCount()));
renderCoverageAttributes(result.getCoverage(false), writer);
diff --git a/container-search/src/main/java/com/yahoo/search/result/Coverage.java b/container-search/src/main/java/com/yahoo/search/result/Coverage.java
index e340132a507..fe59bc9088a 100644
--- a/container-search/src/main/java/com/yahoo/search/result/Coverage.java
+++ b/container-search/src/main/java/com/yahoo/search/result/Coverage.java
@@ -6,31 +6,40 @@ import com.google.common.annotations.Beta;
/**
* The coverage report for a result set.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
* @author baldersheim
*/
public class Coverage extends com.yahoo.container.handler.Coverage {
public Coverage(long docs, long active) {
- this(docs, active, 0);
+ this(docs, active, docs > 1 ? 1 : 0, docs > 1 ? 1: 0);
}
public Coverage(long docs, long active, int nodes) {
super(docs, active, nodes, 1);
}
- @Deprecated
+ public Coverage(long docs, long active, int nodes, int resultSets) {
+ super(docs, active, nodes, resultSets);
+ }
+
+ // TODO: Remove on Vespa 7
+ /** @deprecated don't send a "full" boolean */
+ @Deprecated // OK
public Coverage(long docs, int nodes, boolean full) {
this(docs, nodes, full, 1);
}
- @Deprecated
+ // TODO: Remove on Vespa 7
+ /** @deprecated don't send a "full" boolean */
+ @Deprecated // OK
public Coverage(long docs, int nodes, boolean full, int resultSets) {
super(docs, nodes, full, resultSets);
}
/**
* Will set number of documents present in ideal state
+ *
* @param soonActive Number of documents active in ideal state
* @return self for chaining
*/
@@ -39,6 +48,7 @@ public class Coverage extends com.yahoo.container.handler.Coverage {
/**
* Will set the reasons for degraded coverage as reported by vespa backend.
+ *
* @param degradedReason Reason for degradation
* @return self for chaining
*/
diff --git a/container-search/src/main/java/com/yahoo/search/result/DefaultErrorHit.java b/container-search/src/main/java/com/yahoo/search/result/DefaultErrorHit.java
index 16b07a86131..54b83544b1a 100644
--- a/container-search/src/main/java/com/yahoo/search/result/DefaultErrorHit.java
+++ b/container-search/src/main/java/com/yahoo/search/result/DefaultErrorHit.java
@@ -63,7 +63,7 @@ public class DefaultErrorHit extends Hit implements ErrorHit, Cloneable {
* @deprecated use {@link #errors()}
*/
@Override
- @Deprecated
+ @Deprecated // OK
// TODO: Remove on Vespa 7
public ErrorMessage getMainError() {
return errors.get(0);
diff --git a/container-search/src/main/java/com/yahoo/search/result/ErrorHit.java b/container-search/src/main/java/com/yahoo/search/result/ErrorHit.java
index 802af478fa2..091c8d67793 100644
--- a/container-search/src/main/java/com/yahoo/search/result/ErrorHit.java
+++ b/container-search/src/main/java/com/yahoo/search/result/ErrorHit.java
@@ -20,7 +20,7 @@ public interface ErrorHit extends Cloneable {
* @deprecated use errors().iterator().next()
*/
// TODO: Remove on Vespa 7
- @Deprecated
+ @Deprecated // OK
ErrorMessage getMainError();
/**
diff --git a/container-search/src/main/java/com/yahoo/search/result/Hit.java b/container-search/src/main/java/com/yahoo/search/result/Hit.java
index 74c31aa33c5..c5132549d05 100644
--- a/container-search/src/main/java/com/yahoo/search/result/Hit.java
+++ b/container-search/src/main/java/com/yahoo/search/result/Hit.java
@@ -484,7 +484,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
*
* @deprecated do not use
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public void changeFieldKey(String oldKey, String newKey) {
Map<String,Object> fieldMap = getFieldMap();
Object value = fieldMap.remove(oldKey);
@@ -515,18 +516,22 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
}
/** Generate a HitField from a field if the field exists */
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public HitField buildHitField(String key) {
return buildHitField(key, false);
}
/** Generate a HitField from a field if the field exists */
@SuppressWarnings("deprecation")
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public HitField buildHitField(String key, boolean forceNoPreTokenize) {
return buildHitField(key, forceNoPreTokenize, false);
}
- // TODO: Remove third parameter on Vespa 7
- @Deprecated
+ // TODO: Remove third parameter on Vespa 7 (set always true)
+ @Deprecated // OK
public HitField buildHitField(String key, boolean forceNoPreTokenize, boolean forceStringHandling) {
Object o = getField(key);
if (o == null) return null;
@@ -555,7 +560,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
public Set<String> types() { return types; }
/** @deprecated do not use */
- @Deprecated
+ // TODO: FRemove on Vespa 7
+ @Deprecated // OK
public String getTypeString() {
return types().stream().collect(Collectors.joining(" "));
}
@@ -568,7 +574,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
*
* @deprecated do not use
*/
- @Deprecated // TODO: Make package private on Vespa 7
+ // TODO: Make package private on Vespa 7
+ @Deprecated // OK
public int getAddNumber() { return addNumber; }
/**
@@ -577,7 +584,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
*
* @deprecated do not use
*/
- @Deprecated // TODO: Make package private on Vespa 7
+ // TODO: Make package private on Vespa 7
+ @Deprecated // OK
public void setAddNumber(int addNumber) { this.addNumber = addNumber; }
/**
@@ -603,11 +611,13 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
public void setAuxiliary(boolean auxiliary) { this.auxiliary = auxiliary; }
/** @deprecated do not use */
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public int getSourceNumber() { return sourceNumber; }
/** @deprecated do not use */
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public void setSourceNumber(int number) { this.sourceNumber = number; }
/** Returns the query which produced this hit, or null if not known */
@@ -630,7 +640,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
* @deprecated do not use
* @return a field of this hit, or null if the property is not set
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public String getFieldXML(String key) {
Object p = getField(key);
@@ -648,7 +659,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
/**
* @deprecated do not use
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public String getUnboldedField(String key, boolean escape) {
Object p = getField(key);
@@ -717,7 +729,8 @@ public class Hit extends ListenableFreezableClass implements Data, Comparable<Hi
/**
* @deprecated do not use
*/
- @Deprecated // TODO: Remove on Vespa 7
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public static String stripCharacter(char strip, String toStripFrom) {
StringBuilder builder = null;
diff --git a/container-search/src/main/java/com/yahoo/search/result/HitGroup.java b/container-search/src/main/java/com/yahoo/search/result/HitGroup.java
index c008b133595..3d5cbab2865 100644
--- a/container-search/src/main/java/com/yahoo/search/result/HitGroup.java
+++ b/container-search/src/main/java/com/yahoo/search/result/HitGroup.java
@@ -389,7 +389,7 @@ public class HitGroup extends Hit implements DataList<Hit>, Cloneable, Iterable<
* @deprecated prefer addError to add some error information.
*/
// TODO: Remove on Vespa 7
- @Deprecated
+ @Deprecated // OK
public void setError(ErrorMessage error) {
addError(error);
}
diff --git a/container-search/src/main/java/com/yahoo/search/result/Templating.java b/container-search/src/main/java/com/yahoo/search/result/Templating.java
index 9e191a1219c..a8b1eedf528 100644
--- a/container-search/src/main/java/com/yahoo/search/result/Templating.java
+++ b/container-search/src/main/java/com/yahoo/search/result/Templating.java
@@ -18,7 +18,8 @@ import com.yahoo.search.query.Presentation;
* @author Steinar Knutsen
* @deprecated do not use
*/
-@Deprecated // TODO: Remove on Vespa 7
+@Deprecated // OK (But wait for deprecated handlers in vespaclient-container-plugin to be removed)
+// TODO: Remove on Vespa 7
public class Templating {
private final Result result;
@@ -155,8 +156,12 @@ public class Templating {
* Returns the templates which will render the result. This is never null.
* If default rendering is used, it is a TemplateSet containing no
* templates.
+ *
+ * @deprecated use a renderer instead
*/
@SuppressWarnings("rawtypes")
+ // TODO: Remove on Vespa 7
+ @Deprecated // OK
public UserTemplate getTemplates() {
if (renderer == null) {
return TemplateSet.getDefault();
@@ -187,7 +192,6 @@ public class Templating {
/**
* @deprecated since 5.1.21, use {@link Presentation#getRenderer()}
*/
- @Deprecated // OK Do not remove on Vespa 6. Remove when we move everything having to do with templates
public Renderer<Result> getRenderer() {
return renderer;
}
@@ -195,7 +199,6 @@ public class Templating {
/**
* @deprecated since 5.1.21, use {@link Presentation#setRenderer(com.yahoo.component.ComponentSpecification)}
*/
- @Deprecated // OK Do not remove on Vespa 6. Remove when we move everything having to do with templates
public void setRenderer(Renderer<Result> renderer) {
this.renderer = renderer;
}
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/HttpProviderSpec.java b/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/HttpProviderSpec.java
index 4103514c103..d38c481e33b 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/HttpProviderSpec.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/model/federation/HttpProviderSpec.java
@@ -14,9 +14,13 @@ import java.util.List;
* Specifies how a http provider is to be set up.
*
* @author Tony Vaagenes
+ * @deprecated
*/
@Immutable
+@Deprecated // OK
+// TODO: Remove on Vespa 7
public class HttpProviderSpec {
+
public enum Type {
vespa(com.yahoo.search.federation.vespa.VespaSearcher.class);
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
index e8af1b8e0ac..7e1afe518af 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
@@ -72,7 +72,19 @@ public class DocsumDefinitionTestCase {
assertEquals("1", hit.getField("EXTINFOSOURCE").toString());
assertEquals("10", hit.getField("LANG1").toString());
assertEquals("352", hit.getField("WORDS").toString());
- assertEquals("index:null/0/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
+ assertEquals("index:null/0/" + asHexString(hit.getGlobalId()), hit.getId().toString());
+ }
+
+ private static String asHexString(GlobalId gid) {
+ StringBuilder sb = new StringBuilder();
+ byte[] rawGid = gid.getRawId();
+ for (byte b : rawGid) {
+ String hex = Integer.toHexString(0xFF & b);
+ if (hex.length() == 1)
+ sb.append('0');
+ sb.append(hex);
+ }
+ return sb.toString();
}
public static GlobalId createGlobalId(int docId) {
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 9c10078fdc0..b08aef6ecb1 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
@@ -6,6 +6,7 @@ import com.yahoo.component.chain.Chain;
import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.container.handler.VipStatus;
import com.yahoo.container.search.Fs4Config;
+import com.yahoo.document.GlobalId;
import com.yahoo.fs4.mplex.*;
import com.yahoo.fs4.test.QueryTestCase;
import com.yahoo.language.simple.SimpleLinguistics;
@@ -518,8 +519,6 @@ public class FastSearcherTestCase {
Chain<Searcher> chain = new Chain<>(fastSearcher);
Execution e = new Execution(chain, Execution.Context.createContextStub());
Pong pong = e.ping(new Ping());
- assertTrue(pong.getPongPacket().isPresent());
- assertEquals(127, pong.getPongPacket().get().getDocstamp());
backend.shutdown();
server.dispatch.socket.close();
server.dispatch.connection.close();
@@ -543,11 +542,22 @@ public class FastSearcherTestCase {
hit.getField("TITLE"));
assertEquals("352", hit.getField("WORDS").toString());
assertEquals(2003., hit.getRelevance().getScore(), 0.01d);
- assertEquals("index:testhittype/234/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
+ assertEquals("index:testhittype/234/" + asHexString(hit.getGlobalId()), hit.getId().toString());
assertEquals("9190", hit.getField("BYTES").toString());
assertEquals("testhittype", hit.getSource());
}
+ private static String asHexString(GlobalId gid) {
+ StringBuilder sb = new StringBuilder();
+ byte[] rawGid = gid.getRawId();
+ for (byte b : rawGid) {
+ String hex = Integer.toHexString(0xFF & b);
+ if (hex.length() == 1)
+ sb.append('0');
+ sb.append(hex);
+ }
+ return sb.toString();
+ }
@Test
public void null_summary_is_included_in_trace() {
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java
index a8eeaeda2a0..fb43fa0421f 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java
@@ -3,12 +3,15 @@ package com.yahoo.prelude.query.parser.test;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.search.Query;
import com.yahoo.search.searchchain.Execution;
import org.junit.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.util.Collections;
import static org.junit.Assert.assertEquals;
@@ -21,10 +24,12 @@ public class ExactMatchAndDefaultIndexTestCase {
@Test
public void testExactMatchTokenization() {
+ SearchDefinition sd = new SearchDefinition("testsd");
Index index = new Index("testexact");
index.setExact(true, null);
- IndexFacts facts = new IndexFacts();
- facts.addIndex("testsd", index);
+ sd.addIndex(index);
+ IndexFacts facts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
+
Query q = new Query("?query=" + enc("a/b foo.com") + "&default-index=testexact");
q.getModel().setExecution(new Execution(new Execution.Context(null, facts, null, null, null)));
assertEquals("AND testexact:a/b testexact:foo.com", q.getModel().getQueryTree().getRoot().toString());
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java
index 9181ea4e268..12f9ef2b18f 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java
@@ -4,6 +4,8 @@ package com.yahoo.prelude.query.parser.test;
import com.yahoo.language.Language;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.CompositeItem;
import com.yahoo.prelude.query.IntItem;
@@ -22,6 +24,7 @@ import com.yahoo.prelude.query.parser.TestLinguistics;
import com.yahoo.search.Query;
import org.junit.Test;
+import java.util.Collections;
import java.util.Iterator;
import static org.junit.Assert.assertEquals;
@@ -2058,13 +2061,17 @@ public class ParseTestCase {
@Test
public void testExactMatchParsing1() {
- IndexFacts indexFacts = ParsingTester.createIndexFacts();
- Index index1=new Index("testexact1");
- index1.setExact(true,null);
- Index index2=new Index("testexact2");
- index2.setExact(true,"()/aa*::*&");
- indexFacts.addIndex("testsd",index1);
- indexFacts.addIndex("testsd",index2);
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
+ index1.setExact(true, null);
+ sd.addIndex(index1);
+
+ Index index2 = new Index("testexact2");
+ index2.setExact(true, "()/aa*::*&");
+ sd.addIndex(index2);
+
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
ParsingTester customTester = new ParsingTester(indexFacts);
customTester.assertParsed("testexact1:/,%&#", "testexact1:/,%&#", Query.Type.ALL);
@@ -2076,10 +2083,13 @@ public class ParseTestCase {
/** Testing terminators containing control characters in conjunction with those control characters */
@Test
public void testExactMatchParsing2() {
- IndexFacts indexFacts = ParsingTester.createIndexFacts();
- Index index1=new Index("testexact1");
- index1.setExact(true,"*!*");
- indexFacts.addIndex("testsd",index1);
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
+ index1.setExact(true, "*!*");
+ sd.addIndex(index1);
+
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
ParsingTester customTester = new ParsingTester(indexFacts);
customTester.assertParsed("testexact1:_-_*!200","testexact1:_-_*!**!!",Query.Type.ALL);
@@ -2088,10 +2098,13 @@ public class ParseTestCase {
/** Testing terminators containing control characters in conjunction with those control characters */
@Test
public void testExactMatchParsing3() {
- IndexFacts indexFacts = ParsingTester.createIndexFacts();
- Index index1=new Index("testexact1");
- index1.setExact(true,"*");
- indexFacts.addIndex("testsd",index1);
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
+ index1.setExact(true, "*");
+ sd.addIndex(index1);
+
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
ParsingTester customTester = new ParsingTester(indexFacts);
customTester.assertParsed("testexact1:_-_*!200","testexact1:_-_**!!",Query.Type.ALL);
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java
index 778802e065c..70fc5d56ab9 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java
@@ -4,6 +4,8 @@ package com.yahoo.prelude.query.parser.test;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.parser.SpecialTokenRegistry;
import com.yahoo.prelude.query.parser.SpecialTokens;
import com.yahoo.prelude.query.parser.Token;
@@ -304,13 +306,17 @@ public class TokenizerTestCase {
@Test
public void testExactMatchTokenization() {
- Index index1=new Index("testexact1");
- index1.setExact(true,null);
- Index index2=new Index("testexact2");
- index2.setExact(true,"()/aa*::*&");
- IndexFacts facts = new IndexFacts();
- facts.addIndex("testsd",index1);
- facts.addIndex("testsd",index2);
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
+ index1.setExact(true, null);
+ sd.addIndex(index1);
+
+ Index index2 = new Index("testexact2");
+ index2.setExact(true, "()/aa*::*&");
+ sd.addIndex(index2);
+
+ IndexFacts facts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
IndexFacts.Session session = facts.newSession(Collections.emptySet(), Collections.emptySet());
Tokenizer tokenizer=new Tokenizer(new SimpleLinguistics());
List<?> tokens=tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*& b:c", "default", session);
@@ -344,16 +350,20 @@ public class TokenizerTestCase {
@Test
public void testExactMatchTokenizationTerminatorTerminatesQuery() {
- Index index1=new Index("testexact1");
- index1.setExact(true,null);
- Index index2=new Index("testexact2");
- index2.setExact(true,"()/aa*::*&");
- IndexFacts facts = new IndexFacts();
- facts.addIndex("testsd",index1);
- facts.addIndex("testsd",index2);
- Tokenizer tokenizer=new Tokenizer(new SimpleLinguistics());
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
+ index1.setExact(true, null);
+ sd.addIndex(index1);
+
+ Index index2 = new Index("testexact2");
+ index2.setExact(true, "()/aa*::*&");
+ sd.addIndex(index2);
+
+ IndexFacts facts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
+ Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
IndexFacts.Session session = facts.newSession(Collections.emptySet(), Collections.emptySet());
- List<?> tokens=tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*&", session);
+ List<?> tokens = tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*&", session);
assertEquals(new Token(WORD, "normal"), tokens.get(0));
assertEquals(new Token(SPACE, " "), tokens.get(1));
assertEquals(new Token(WORD, "a"), tokens.get(2));
@@ -377,16 +387,20 @@ public class TokenizerTestCase {
@Test
public void testExactMatchTokenizationWithTerminatorTerminatedByEndOfString() {
- Index index1=new Index("testexact1");
- index1.setExact(true,null);
- Index index2=new Index("testexact2");
- index2.setExact(true,"()/aa*::*&");
- IndexFacts facts = new IndexFacts();
- facts.addIndex("testsd",index1);
- facts.addIndex("testsd",index2);
- Tokenizer tokenizer=new Tokenizer(new SimpleLinguistics());
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
+ index1.setExact(true, null);
+ sd.addIndex(index1);
+
+ Index index2 = new Index("testexact2");
+ index2.setExact(true, "()/aa*::*&");
+ sd.addIndex(index2);
+
+ IndexFacts facts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
+ Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
IndexFacts.Session session = facts.newSession(Collections.emptySet(), Collections.emptySet());
- List<?> tokens=tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*", session);
+ List<?> tokens = tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*", session);
assertEquals(new Token(WORD, "normal"), tokens.get(0));
assertEquals(new Token(SPACE, " "), tokens.get(1));
assertEquals(new Token(WORD, "a"), tokens.get(2));
@@ -410,16 +424,20 @@ public class TokenizerTestCase {
@Test
public void testExactMatchTokenizationEndsByColon() {
- Index index1=new Index("testexact1");
- index1.setExact(true,null);
- Index index2=new Index("testexact2");
- index2.setExact(true,"()/aa*::*&");
- IndexFacts facts = new IndexFacts();
- facts.addIndex("testsd",index1);
- facts.addIndex("testsd",index2);
- Tokenizer tokenizer=new Tokenizer(new SimpleLinguistics());
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
+ index1.setExact(true, null);
+ sd.addIndex(index1);
+
+ Index index2 = new Index("testexact2");
+ index2.setExact(true, "()/aa*::*&");
+ sd.addIndex(index2);
+
+ IndexFacts facts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
+ Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
IndexFacts.Session session = facts.newSession(Collections.emptySet(), Collections.emptySet());
- List<?> tokens=tokenizer.tokenize("normal a:b (normal testexact1:!/%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*&b:", session);
+ List<?> tokens = tokenizer.tokenize("normal a:b (normal testexact1:!/%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*&b:", session);
assertEquals(new Token(WORD, "normal"), tokens.get(0));
assertEquals(new Token(SPACE, " "), tokens.get(1));
assertEquals(new Token(WORD, "a"), tokens.get(2));
@@ -444,13 +462,17 @@ public class TokenizerTestCase {
@Test
public void testExactMatchHeuristics() {
- Index index1=new Index("testexact1");
+ SearchDefinition sd = new SearchDefinition("testsd");
+
+ Index index1 = new Index("testexact1");
index1.setExact(true, null);
- Index index2=new Index("testexact2");
+ sd.addIndex(index1);
+
+ Index index2 = new Index("testexact2");
index2.setExact(true, "()/aa*::*&");
- IndexFacts indexFacts = new IndexFacts();
- indexFacts.addIndex("testsd", index1);
- indexFacts.addIndex("testsd", index2);
+ sd.addIndex(index2);
+
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
IndexFacts.Session facts = indexFacts.newSession(Collections.emptySet(), Collections.emptySet());
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/IndexCombinatorTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/IndexCombinatorTestCase.java
deleted file mode 100644
index 7858bbf6433..00000000000
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/IndexCombinatorTestCase.java
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.prelude.querytransform.test;
-
-import com.yahoo.config.subscription.ConfigGetter;
-import com.yahoo.container.QrSearchersConfig;
-import com.yahoo.search.config.IndexInfoConfig;
-import com.yahoo.prelude.Index;
-import com.yahoo.prelude.IndexFacts;
-import com.yahoo.prelude.IndexModel;
-import com.yahoo.search.Query;
-import com.yahoo.prelude.querytransform.IndexCombinatorSearcher;
-import com.yahoo.search.Result;
-import com.yahoo.search.Searcher;
-import com.yahoo.search.searchchain.Execution;
-import com.yahoo.search.test.QueryTestCase;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Control query transformations when doing index name expansion in QRS.
- *
- * @author Steinar Knutsen
- */
-public class IndexCombinatorTestCase {
-
- private Searcher transformer;
- private IndexFacts f;
-
- @Before
- public void setUp() throws Exception {
- transformer = new IndexCombinatorSearcher();
- f = new IndexFacts();
- f.addIndex("one", "z");
- Index i = new Index("default");
- i.addCommand("match-group a i");
- f.addIndex("one", i);
- }
-
- @Test
- public void testDoNothing() {
- Result r = search("?query=z:y");
- assertEquals("z:y", r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- private Result search(String query) {
- return new Execution(transformer, Execution.Context.createContextStub(f)).search(new Query(QueryTestCase.httpEncode(query)));
- }
-
- @Test
- public void testBasic() {
- Result r = search("?query=y");
- assertEquals("OR a:y i:y", r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testBasicPair() {
- Result r = search("?query=x y");
- assertEquals(
- "OR (AND a:x a:y) (AND a:x i:y) (AND i:x a:y) (AND i:x i:y)", r
- .getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testBasicTriplet() {
- Result r = search("?query=x y z");
- assertEquals("AND (OR a:x i:x) (OR a:y i:y) (OR a:z i:z)", r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testBasicMixedSinglet() {
- Result r = search("?query=x z:q");
- assertEquals("OR (AND a:x z:q) (AND i:x z:q)", r.getQuery().getModel().getQueryTree().getRoot()
- .toString());
- }
-
- @Test
- public void testBasicMixedPair() {
- Result r = search("?query=x y z:q");
- assertEquals(
- "OR (AND a:x a:y z:q) (AND a:x i:y z:q) (AND i:x a:y z:q) (AND i:x i:y z:q)",
- r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testBasicMixedTriplet() {
- Result r = search("?query=x y z:q r");
- assertEquals("AND (OR a:x i:x) (OR a:y i:y) z:q (OR a:r i:r)", r
- .getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testBasicOr() {
- Result r = search("?query=x y&type=any");
- assertEquals("OR a:y i:y a:x i:x", r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testBasicPhrase() {
- Result r = search("?query=\"x y\"");
- assertEquals("OR a:x y i:x y", r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testPhraseAndTerm() {
- Result r = search("?query=\"x y\" z");
- assertEquals(
- "OR (AND a:x y a:z) (AND a:x y i:z) (AND i:x y a:z) (AND i:x y i:z)",
- r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testBasicNot() {
- Result r = search("?query=+x -y");
- assertEquals("+(OR a:x i:x) -(OR a:y i:y)", r.getQuery().getModel().getQueryTree().getRoot()
- .toString());
- }
-
- @Test
- public void testLessBasicNot() {
- Result r = search("?query=a and b andnot c&type=adv");
- assertEquals(
- "+(OR (AND a:a a:b) (AND a:a i:b) (AND i:a a:b) (AND i:a i:b)) -(OR a:c i:c)",
- r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testLongerAndInPositive() {
- Result r = search("?query=a and b and c andnot d&type=adv");
- assertEquals(
- "+(AND (OR a:a i:a) (OR a:b i:b) (OR a:c i:c)) -(OR a:d i:d)", r
- .getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testTreeInNegativeBranch() {
- Result r = search("?query=a andnot (b and c)&type=adv");
- assertEquals("+(OR a:a i:a) -(AND (OR a:b i:b) (OR a:c i:c))", r
- .getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testSomeTerms() {
- Result r = search("?query=a b -c +d g.h \"abc def\" z:q");
- assertEquals(
- "+(AND (OR a:a i:a) (OR a:b i:b) (OR a:d i:d) (OR a:g h i:g h) (OR a:abc def i:abc def) z:q) -(OR a:c i:c)",
- r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
- @Test
- public void testMixedIndicesAndAttributes() {
- String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/querytransform/test/indexcombinator.cfg";
- ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
- IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
- IndexFacts facts = new IndexFacts(new IndexModel(config, (QrSearchersConfig)null));
-
- Result r = new Execution(transformer, Execution.Context.createContextStub(facts)).search(new Query(QueryTestCase.httpEncode("?query=\"a b\"")));
- assertEquals("OR default:\"a b\" attribute1:a b attribute2:a b", r
- .getQuery().getModel().getQueryTree().getRoot().toString());
- r = new Execution(transformer, Execution.Context.createContextStub(facts)).search(new Query(QueryTestCase.httpEncode("?query=\"a b\" \"c d\"")));
- assertEquals(
- "OR (AND default:\"a b\" default:\"c d\")"
- + " (AND default:\"a b\" attribute1:c d)"
- + " (AND default:\"a b\" attribute2:c d)"
- + " (AND attribute1:a b default:\"c d\")"
- + " (AND attribute1:a b attribute1:c d)"
- + " (AND attribute1:a b attribute2:c d)"
- + " (AND attribute2:a b default:\"c d\")"
- + " (AND attribute2:a b attribute1:c d)"
- + " (AND attribute2:a b attribute2:c d)",
- r.getQuery().getModel().getQueryTree().getRoot().toString());
- }
-
-}
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ErrorHitRenderTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ErrorHitRenderTestCase.java
deleted file mode 100644
index 7c170cc59b3..00000000000
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ErrorHitRenderTestCase.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.prelude.searcher.test;
-
-import com.yahoo.prelude.templates.SearchRendererAdaptor;
-import com.yahoo.search.result.DefaultErrorHit;
-import com.yahoo.search.result.ErrorHit;
-import com.yahoo.search.result.ErrorMessage;
-import com.yahoo.text.XMLWriter;
-import org.junit.Test;
-
-import java.io.StringWriter;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests marking hit properties as XML
- *
- * @author Steinar Knutsen
- */
-public class ErrorHitRenderTestCase {
-
- @Test
- public void testXMLEscaping() throws java.io.IOException {
- ErrorHit h = new DefaultErrorHit("testcase", ErrorMessage.createUnspecifiedError("<>\"&"));
-
- StringWriter writer = new StringWriter();
- SearchRendererAdaptor.renderMessageDefaultErrorHit(new XMLWriter(writer), h.errors().iterator().next());
- assertEquals("<error source=\"testcase\" error=\"Unspecified error\" code=\"5\">&lt;&gt;\"&amp;</error>\n",
- writer.toString());
- }
-
-}
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
index fa27d4d47f5..88c06635520 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
@@ -3,12 +3,14 @@ package com.yahoo.prelude.test;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import com.google.common.collect.ImmutableList;
import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.search.config.IndexInfoConfig;
@@ -31,6 +33,7 @@ import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Tests using synthetic index names for IndexFacts class.
@@ -45,7 +48,14 @@ public class IndexFactsTestCase {
private IndexFacts createIndexFacts() {
ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
IndexInfoConfig config = getter.getConfig(INDEXFACTS_TESTING);
+ return new IndexFacts(new IndexModel(config, createClusters()));
+ }
+
+ private IndexFacts createIndexFacts(Collection<SearchDefinition> searchDefinitions) {
+ return new IndexFacts(new IndexModel(createClusters(), searchDefinitions));
+ }
+ private Map<String, List<String>> createClusters() {
List<String> clusterOne = new ArrayList<>();
List<String> clusterTwo = new ArrayList<>();
clusterOne.addAll(Arrays.asList("one", "two"));
@@ -53,9 +63,7 @@ public class IndexFactsTestCase {
Map<String, List<String>> clusters = new HashMap<>();
clusters.put("clusterOne", clusterOne);
clusters.put("clusterTwo", clusterTwo);
- IndexFacts indexFacts = new IndexFacts(new IndexModel(config, clusters));
-
- return indexFacts;
+ return clusters;
}
@Test
@@ -66,11 +74,6 @@ public class IndexFactsTestCase {
assertEquals("a:b", q.getModel().getQueryTree().getRoot().toString());
q = newQuery("?query=notarealindex:b", indexFacts);
assertEquals("\"notarealindex b\"", q.getModel().getQueryTree().getRoot().toString());
-
- // Add an index to an SD which also happens to be the default
- indexFacts.addIndex("one", "yetanothersynthetic");
- q = newQuery("?query=yetanothersynthetic:b", indexFacts);
- assertEquals("yetanothersynthetic:b", q.getModel().getQueryTree().getRoot().toString());
}
@Test
@@ -88,16 +91,13 @@ public class IndexFactsTestCase {
sd.addCommand("c", "default-position");
assertTrue(sd.getDefaultPosition().equals("c"));
- SearchDefinition sd2 = new SearchDefinition("sd");
+ SearchDefinition sd2 = new SearchDefinition("sd2");
sd2.addIndex(new Index("b").addCommand("any"));
assertNull(sd2.getDefaultPosition());
sd2.addIndex(a);
assertTrue(sd2.getDefaultPosition().equals("a"));
- Map<String,SearchDefinition> m = new TreeMap<>();
- m.put(sd.getName(), sd);
- IndexFacts indexFacts = createIndexFacts();
- indexFacts.setSearchDefinitions(m,sd2);
+ IndexFacts indexFacts = createIndexFacts(ImmutableList.of(sd, sd2));
assertTrue(indexFacts.getDefaultPosition(null).equals("a"));
assertTrue(indexFacts.getDefaultPosition("sd").equals("c"));
}
@@ -134,10 +134,13 @@ public class IndexFactsTestCase {
}
private void assertExactIsWorking(String indexName) {
- Index index=new Index(indexName);
+ SearchDefinition sd = new SearchDefinition("artist");
+
+ Index index = new Index(indexName);
index.setExact(true,"^^^");
- IndexFacts indexFacts = createIndexFacts();
- indexFacts.addIndex("artist",index);
+ sd.addIndex(index);
+
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
Query query = new Query();
query.getModel().getSources().add("artist");
assertTrue(indexFacts.newSession(query).getIndex(indexName).isExact());
@@ -150,7 +153,7 @@ public class IndexFactsTestCase {
assertExactIsWorking("test");
assertExactIsWorking("artist_name_ft_norm1");
- List search=new ArrayList();
+ List search = new ArrayList();
search.add("three");
Query query = new Query();
query.getModel().getSources().add("three");
@@ -176,13 +179,15 @@ public class IndexFactsTestCase {
@Test
public void testComplexExactMatching() {
- IndexFacts indexFacts = createIndexFacts();
+ SearchDefinition sd = new SearchDefinition("foobar");
String u_name = "foo_bar";
Index u_index = new Index(u_name);
u_index.setExact(true, "^^^");
Index b_index = new Index("bar");
- indexFacts.addIndex("foobar", u_index);
- indexFacts.addIndex("foobar", b_index);
+ sd.addIndex(u_index);
+ sd.addIndex(b_index);
+
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
Query query = new Query();
query.getModel().getSources().add("foobar");
IndexFacts.Session session = indexFacts.newSession(query);
@@ -253,15 +258,14 @@ public class IndexFactsTestCase {
new Indexinfo.Builder().name("music").command(
new Command.Builder().indexname("title")
.command("index"))));
- IndexModel m = new IndexModel(cfg, (QrSearchersConfig)null);
- assertNotNull(m.getSearchDefinitions().get("music").getIndex("title"));
- assertNull(m.getSearchDefinitions().get("music").getIndex("btitle"));
- assertNotNull(m.getSearchDefinitions().get("music2").getIndex("btitle"));
- assertNotNull(m.getSearchDefinitions().get("music2").getIndex("title"));
- assertSame(m.getSearchDefinitions().get("music2").getIndex("btitle"),
- m.getSearchDefinitions().get("music2").getIndex("title"));
- assertNotSame(m.getSearchDefinitions().get("music").getIndex("title"),
- m.getSearchDefinitions().get("music2").getIndex("title"));
+ try {
+ new IndexModel(cfg, (QrSearchersConfig) null);
+ fail("Excepted exception"); // (This is validated at deploy time)
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("Tried adding the alias 'title' for the index name 'btitle' when the name 'title' already maps to 'title'",
+ e.getMessage());
+ }
}
private Query newQuery(String queryString, IndexFacts indexFacts) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java
index 2d46ff8e177..627dbb13cbe 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java
@@ -4,7 +4,10 @@ package com.yahoo.prelude.test;
import com.yahoo.language.Language;
import com.yahoo.language.Linguistics;
import com.yahoo.language.simple.SimpleLinguistics;
+import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.QueryException;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.search.Query;
@@ -16,6 +19,7 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import java.util.Collections;
import java.util.List;
import static org.hamcrest.CoreMatchers.containsString;
@@ -31,18 +35,6 @@ import static org.junit.Assume.assumeTrue;
*/
public class QueryTestCase {
- private final IndexFacts facts = new IndexFacts();
-
- @Before
- public void setUp() {
- // Setup the indices we expect
- facts.addIndex(null,"fast.type");
- facts.addIndex(null,"def");
- facts.addIndex(null,"default");
- facts.addIndex(null,"keyword");
- facts.addIndex(null,"content");
- }
-
/**
* Basic test
*/
@@ -377,9 +369,23 @@ public class QueryTestCase {
return newQueryFromEncoded(com.yahoo.search.test.QueryTestCase.httpEncode(queryString), language, linguistics);
}
+ private IndexFacts createIndexFacts() {
+ SearchDefinition sd = new SearchDefinition("test");
+ sd.addIndex(new Index("fast.type"));
+ sd.addIndex(new Index("def"));
+ sd.addIndex(new Index("default"));
+ sd.addIndex(new Index("keyword"));
+ sd.addIndex(new Index("content"));
+ return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
+ }
+
private Query newQueryFromEncoded(String encodedQueryString, Language language, Linguistics linguistics) {
Query query = new Query(encodedQueryString);
- query.getModel().setExecution(new Execution(new Execution.Context(null, facts, null, null, linguistics)));
+ query.getModel().setExecution(new Execution(new Execution.Context(null,
+ createIndexFacts(),
+ null,
+ null,
+ linguistics)));
query.getModel().setLanguage(language);
return query;
}
diff --git a/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java
index bb73e1f4217..b9b29f5fc2b 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
@@ -14,6 +15,7 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
import org.junit.Test;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -36,10 +38,9 @@ public class DuplicateSourceTestCase {
MockBackendSearcher mockBackendSearcher = new MockBackendSearcher();
SearchChainRegistry searchChains = new SearchChainRegistry();
searchChains.register(new Chain<>("chain1", mockBackendSearcher));
- IndexFacts indexFacts = new IndexFacts();
Map<String, List<String>> clusters = new HashMap<>();
clusters.put("chain1", ImmutableList.of("doc1", "doc2"));
- indexFacts.setClusters(clusters);
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, Collections.emptyList()));
SearchChainResolver resolver = new SearchChainResolver.Builder()
.addSearchChain(new ComponentId("chain1"), ImmutableList.of("doc1", "doc2"))
.build();
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
index 4cd091098fe..b6b71a3e00c 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
@@ -37,11 +37,11 @@ public class HitConverterTestCase {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
Hit hit = converter.toSearchHit("default", new FS4Hit(1, createGlobalId(2), 3).setContext(context()));
assertNotNull(hit);
- assertEquals(new URI("index:null/1/" + FastHit.asHexString(createGlobalId(2))), hit.getId());
+ assertEquals(new URI("index:null/1/" + asHexString(createGlobalId(2))), hit.getId());
hit = converter.toSearchHit("default", new FS4Hit(4, createGlobalId(5), 6).setContext(context()));
assertNotNull(hit);
- assertEquals(new URI("index:null/4/" + FastHit.asHexString(createGlobalId(5))), hit.getId());
+ assertEquals(new URI("index:null/4/" + asHexString(createGlobalId(5))), hit.getId());
}
@Test
@@ -132,6 +132,18 @@ public class HitConverterTestCase {
assertTrue(hit.isFilled("69"));
}
+ private static String asHexString(GlobalId gid) {
+ StringBuilder sb = new StringBuilder();
+ byte[] rawGid = gid.getRawId();
+ for (byte b : rawGid) {
+ String hex = Integer.toHexString(0xFF & b);
+ if (hex.length() == 1)
+ sb.append('0');
+ sb.append(hex);
+ }
+ return sb.toString();
+ }
+
private static class MySearcher extends Searcher {
@Override
@@ -139,4 +151,5 @@ public class HitConverterTestCase {
return exec.search(query);
}
}
+
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceResult.xml
index a1713a987cd..f1b2c823681 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceResult.xml
@@ -1,41 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0">
-
- <hit relevance="1.0" source="source3">
- <id>source3-1</id>
- </hit>
-
- <hit relevance="1.0" source="source1">
- <id>source1-1</id>
- </hit>
-
- <hit relevance="1.0" source="source2">
- <id>source2-1</id>
- </hit>
-
- <hit relevance="0.5" source="source3">
- <id>source3-2</id>
- </hit>
-
- <hit relevance="0.5" source="source1">
- <id>source1-2</id>
- </hit>
-
- <hit relevance="0.5" source="source2">
- <id>source2-2</id>
- </hit>
-
- <hit relevance="0.3333333333333333" source="source3">
- <id>source3-3</id>
- </hit>
-
- <hit relevance="0.3333333333333333" source="source1">
- <id>source1-3</id>
- </hit>
-
- <hit relevance="0.3333333333333333" source="source2">
- <id>source2-3</id>
- </hit>
-
-</result>
+<page version="1.0">
+ <content>
+ <hit relevance="1.0" source="source3">
+ <id>source3-1</id>
+ </hit>
+ <hit relevance="1.0" source="source1">
+ <id>source1-1</id>
+ </hit>
+ <hit relevance="1.0" source="source2">
+ <id>source2-1</id>
+ </hit>
+ <hit relevance="0.5" source="source3">
+ <id>source3-2</id>
+ </hit>
+ <hit relevance="0.5" source="source1">
+ <id>source1-2</id>
+ </hit>
+ <hit relevance="0.5" source="source2">
+ <id>source2-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source3">
+ <id>source3-3</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source1">
+ <id>source1-3</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source2">
+ <id>source2-3</id>
+ </hit>
+ </content>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersResult.xml
index e1ae0b928e6..fc8b2cdc847 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersResult.xml
@@ -1,36 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0">
-
+<page version="1.0">
<renderer name="sectionLook2"/>
-
<renderer for="source1" name="source1Look3">
<parameter name="color">#ff00ff</parameter>
<parameter name="blink">true</parameter>
</renderer>
-
- <hit relevance="1.0" source="source1">
- <id>source1-1</id>
- </hit>
-
- <hit relevance="1.0" source="source2">
- <id>source2-1</id>
- </hit>
-
- <hit relevance="0.5" source="source1">
- <id>source1-2</id>
- </hit>
-
- <hit relevance="0.5" source="source2">
- <id>source2-2</id>
- </hit>
-
- <hit relevance="0.3333333333333333" source="source1">
- <id>source1-3</id>
- </hit>
-
- <hit relevance="0.3333333333333333" source="source2">
- <id>source2-3</id>
- </hit>
-
-</result>
+ <content>
+ <hit relevance="1.0" source="source1">
+ <id>source1-1</id>
+ </hit>
+ <hit relevance="1.0" source="source2">
+ <id>source2-1</id>
+ </hit>
+ <hit relevance="0.5" source="source1">
+ <id>source1-2</id>
+ </hit>
+ <hit relevance="0.5" source="source2">
+ <id>source2-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source1">
+ <id>source1-3</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source2">
+ <id>source2-3</id>
+ </hit>
+ </content>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsResult.xml
index a2cf4b8a773..01af611c51a 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsResult.xml
@@ -1,29 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0">
-
+<page version="1.0">
<section>
- <hit relevance="1.0" source="source2">
- <id>source2-1</id>
- </hit>
- <hit relevance="0.5" source="source2">
- <id>source2-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source2">
- <id>source2-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source2">
+ <id>source2-1</id>
+ </hit>
+ <hit relevance="0.5" source="source2">
+ <id>source2-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source2">
+ <id>source2-3</id>
+ </hit>
+ </content>
</section>
-
<section>
- <hit relevance="1.0" source="source4">
- <id>source4-1</id>
- </hit>
- <hit relevance="0.5" source="source4">
- <id>source4-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source4">
- <id>source4-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source4">
+ <id>source4-1</id>
+ </hit>
+ <hit relevance="0.5" source="source4">
+ <id>source4-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source4">
+ <id>source4-3</id>
+ </hit>
+ </content>
</section>
-
-</result>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java
index 513d861c86c..8c9e1767989 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java
@@ -10,6 +10,9 @@ import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.result.HitGroup;
import org.junit.Test;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
import static org.junit.Assert.assertEquals;
/**
@@ -20,47 +23,49 @@ public class ChoiceOfSubsectionsTestCase extends ExecutionAbstractTestCase {
@Test
public void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("ChoiceOfSubsections.xml"));
+ Choice page = Choice.createSingleton(importPage("ChoiceOfSubsections.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source2",3));
- result.hits().add(createHits("source3",3));
- result.hits().add(createHits("source4",3));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source2", 3));
+ result.hits().add(createHits("source3", 3));
+ result.hits().add(createHits("source4", 3));
- new Organizer().organize(page,new DeterministicResolverAssertingMethod().resolve(page,query,result),result);
+ new Organizer().organize(page, new DeterministicResolverAssertingMethod().resolve(page, query, result), result);
// Check execution:
// Two subsections with one source each
- assertEquals(2,result.hits().size());
- HitGroup section1=(HitGroup)result.hits().get(0);
- HitGroup section2=(HitGroup)result.hits().get(1);
- assertEqualHitGroups(createHits("source2",3),section1);
- assertEqualHitGroups(createHits("source4",3),section2);
+ assertEquals(2, result.hits().size());
+ HitGroup section1 = (HitGroup)result.hits().get(0);
+ HitGroup section2 = (HitGroup)result.hits().get(1);
+ assertEquals("section", section1.types().stream().collect(Collectors.joining(", ")));
+ assertEquals("section", section2.types().stream().collect(Collectors.joining(", ")));
+ assertEqualHitGroups(createHits("source2", 3), section1);
+ assertEqualHitGroups(createHits("source4", 3), section2);
// Check rendering
- assertRendered(result,"ChoiceOfSubsectionsResult.xml");
+ assertRendered(result, "ChoiceOfSubsectionsResult.xml");
}
/** Same as deterministic resolver, but asserts that it received the correct method names for each choice */
private static class DeterministicResolverAssertingMethod extends DeterministicResolver {
- private int invocationNumber=0;
+ private int invocationNumber = 0;
/** Chooses the last alternative of any choice */
@Override
public void resolve(Choice choice, Query query, Result result, Resolution resolution) {
invocationNumber++;
- if (invocationNumber==2)
- assertEquals("method1",choice.getMethod());
- else if (invocationNumber==3)
- assertEquals("method2",choice.getMethod());
- else if (invocationNumber>3)
+ if (invocationNumber == 2)
+ assertEquals("method1", choice.getMethod());
+ else if (invocationNumber == 3)
+ assertEquals("method2", choice.getMethod());
+ else if (invocationNumber > 3)
throw new IllegalStateException("Unexpected number of resolver invocations");
- super.resolve(choice,query,result,resolution);
+ super.resolve(choice, query, result, resolution);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesResult.xml
index 149aa297bd3..c02f7469afd 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesResult.xml
@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0">
-
- <hit relevance="1.0" source="source2">
- <id>source2-1</id>
- </hit>
-
- <hit relevance="0.5" source="source2">
- <id>source2-2</id>
- </hit>
-
- <hit relevance="0.3333333333333333" source="source2">
- <id>source2-3</id>
- </hit>
-
-</result>
+<page version="1.0">
+ <content>
+ <hit relevance="1.0" source="source2">
+ <id>source2-1</id>
+ </hit>
+ <hit relevance="0.5" source="source2">
+ <id>source2-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source2">
+ <id>source2-3</id>
+ </hit>
+ </content>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesResult.xml
index 60f5c9a9cb1..f135f6e1f52 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesResult.xml
@@ -1,55 +1,60 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0">
-
+<page version="1.0">
<section layout="row">
<section id="section:box1">
- <hit relevance="1.0" source="news">
- <id>news-1</id>
- </hit>
- <hit relevance="0.5" source="news">
- <id>news-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="news">
- <id>news-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="news">
+ <id>news-1</id>
+ </hit>
+ <hit relevance="0.5" source="news">
+ <id>news-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="news">
+ <id>news-3</id>
+ </hit>
+ </content>
</section>
<section id="section:box2">
- <hit relevance="1.0" source="web">
- <id>web-1</id>
- </hit>
- <hit relevance="0.5" source="web">
- <id>web-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="web">
- <id>web-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="web">
+ <id>web-1</id>
+ </hit>
+ <hit relevance="0.5" source="web">
+ <id>web-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="web">
+ <id>web-3</id>
+ </hit>
+ </content>
</section>
</section>
-
<section layout="row">
<section id="section:box3">
- <hit relevance="1.0" source="blog">
- <id>blog-1</id>
- </hit>
- <hit relevance="0.5" source="blog">
- <id>blog-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="blog">
- <id>blog-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="blog">
+ <id>blog-1</id>
+ </hit>
+ <hit relevance="0.5" source="blog">
+ <id>blog-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="blog">
+ <id>blog-3</id>
+ </hit>
+ </content>
</section>
<section id="section:box4">
- <hit relevance="1.0" source="images">
- <id>images-1</id>
- </hit>
- <hit relevance="0.5" source="images">
- <id>images-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="images">
- <id>images-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="images">
+ <id>images-1</id>
+ </hit>
+ <hit relevance="0.5" source="images">
+ <id>images-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="images">
+ <id>images-3</id>
+ </hit>
+ </content>
</section>
</section>
-
-</result>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java
index e873d93d8cd..999a6d32ac6 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.pagetemplates.engine.test;
+import com.google.common.util.concurrent.ListenableFuture;
import com.yahoo.io.IOUtils;
import com.yahoo.prelude.templates.TiledTemplateSet;
import com.yahoo.prelude.templates.UserTemplate;
@@ -8,10 +9,13 @@ import com.yahoo.prelude.templates.test.TilingTestCase;
import com.yahoo.search.Result;
import com.yahoo.search.pagetemplates.PageTemplate;
import com.yahoo.search.pagetemplates.config.PageTemplateXMLReader;
+import com.yahoo.search.pagetemplates.result.PageTemplatesXmlRenderer;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
+import com.yahoo.text.Utf8;
import java.io.*;
+import java.util.List;
import static org.junit.Assert.*;
@@ -48,27 +52,36 @@ public class ExecutionAbstractTestCase {
return source;
}
- protected void assertRendered(Result result,String resultFileName) {
+ protected void assertRendered(Result result, String resultFileName) {
assertRendered(result,resultFileName,false);
}
- protected void assertRendered(Result result,String resultFileName, UserTemplate<?> template) {
- assertRendered(result,resultFileName,template,false);
- }
-
- protected void assertRendered(Result result,String resultFileName,boolean print) {
- assertRendered(result,resultFileName,new TiledTemplateSet(),print);
- }
-
@SuppressWarnings("deprecation")
- protected void assertRendered(Result result,String resultFileName,UserTemplate<?> template, boolean print) {
- result.getTemplating().setTemplates(template);
+ protected void assertRendered(Result result, String resultFileName, boolean print) {
try {
- TilingTestCase.assertRendered(IOUtils.readFile(new File(root + resultFileName)), result);
+ PageTemplatesXmlRenderer renderer = new PageTemplatesXmlRenderer();
+ renderer.init();
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ListenableFuture<Boolean> f = renderer.render(stream, result, null, null);
+ assertTrue(f.get());
+ String renderedResult = Utf8.toString(stream.toByteArray());
+ if (print)
+ System.out.println(renderedResult);
+ assertEquals(removeComments(IOUtils.getLines(root + resultFileName)),
+ renderedResult);
}
- catch (IOException e) {
+ catch (Exception e) {
throw new RuntimeException(e);
}
}
+ private String removeComments(List<String> xmlLines) {
+ StringBuilder b = new StringBuilder();
+ for (String line : xmlLines) {
+ if (line.trim().startsWith("<!--")) continue;
+ b.append(line).append('\n');
+ }
+ return b.toString();
+ }
+
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsResult.xml
index 4272e54aeec..5fceca589e4 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsResult.xml
@@ -1,96 +1,103 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0" layout="column">
-
+<page version="1.0" layout="column">
<section layout="row">
<section id="section:box1">
- <hit relevance="1.0" source="source1">
- <id>source1-1</id>
- </hit>
- <hit relevance="0.5" source="source1">
- <id>source1-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source1">
- <id>source1-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source1">
+ <id>source1-1</id>
+ </hit>
+ <hit relevance="0.5" source="source1">
+ <id>source1-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source1">
+ <id>source1-3</id>
+ </hit>
+ </content>
</section>
<section id="section:box2">
- <hit relevance="1.0" source="source2">
- <id>source2-1</id>
- </hit>
- <hit relevance="0.5" source="source2">
- <id>source2-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source2">
- <id>source2-3</id>
- </hit>
- <hit relevance="0.25" source="source2">
- <id>source2-4</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source2">
+ <id>source2-1</id>
+ </hit>
+ <hit relevance="0.5" source="source2">
+ <id>source2-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source2">
+ <id>source2-3</id>
+ </hit>
+ <hit relevance="0.25" source="source2">
+ <id>source2-4</id>
+ </hit>
+ </content>
</section>
</section>
-
<section layout="row">
<section id="section:box3">
- <hit relevance="1.0" source="source3">
- <id>source3-1</id>
- </hit>
- <hit relevance="0.5" source="source3">
- <id>source3-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source3">
- <id>source3-3</id>
- </hit>
- <hit relevance="0.25" source="source3">
- <id>source3-4</id>
- </hit>
- <hit relevance="0.2" source="source3">
- <id>source3-5</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source3">
+ <id>source3-1</id>
+ </hit>
+ <hit relevance="0.5" source="source3">
+ <id>source3-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source3">
+ <id>source3-3</id>
+ </hit>
+ <hit relevance="0.25" source="source3">
+ <id>source3-4</id>
+ </hit>
+ <hit relevance="0.2" source="source3">
+ <id>source3-5</id>
+ </hit>
+ </content>
</section>
<section id="section:box5">
- <hit relevance="1.0" source="source5">
- <id>source5-1</id>
- </hit>
- <hit relevance="0.5" source="source5">
- <id>source5-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source5">
- <id>source5-3</id>
- </hit>
- <hit relevance="0.25" source="source5">
- <id>source5-4</id>
- </hit>
- <hit relevance="0.2" source="source5">
- <id>source5-5</id>
- </hit>
- <hit relevance="0.16666666666666666" source="source5">
- <id>source5-6</id>
- </hit>
- <hit relevance="0.14285714285714285" source="source5">
- <id>source5-7</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source5">
+ <id>source5-1</id>
+ </hit>
+ <hit relevance="0.5" source="source5">
+ <id>source5-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source5">
+ <id>source5-3</id>
+ </hit>
+ <hit relevance="0.25" source="source5">
+ <id>source5-4</id>
+ </hit>
+ <hit relevance="0.2" source="source5">
+ <id>source5-5</id>
+ </hit>
+ <hit relevance="0.16666666666666666" source="source5">
+ <id>source5-6</id>
+ </hit>
+ <hit relevance="0.14285714285714285" source="source5">
+ <id>source5-7</id>
+ </hit>
+ </content>
</section>
<section id="section:box4">
- <hit relevance="1.0" source="source4">
- <id>source4-1</id>
- </hit>
- <hit relevance="0.5" source="source4">
- <id>source4-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source4">
- <id>source4-3</id>
- </hit>
- <hit relevance="0.25" source="source4">
- <id>source4-4</id>
- </hit>
- <hit relevance="0.2" source="source4">
- <id>source4-5</id>
- </hit>
- <hit relevance="0.16666666666666666" source="source4">
- <id>source4-6</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source4">
+ <id>source4-1</id>
+ </hit>
+ <hit relevance="0.5" source="source4">
+ <id>source4-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source4">
+ <id>source4-3</id>
+ </hit>
+ <hit relevance="0.25" source="source4">
+ <id>source4-4</id>
+ </hit>
+ <hit relevance="0.2" source="source4">
+ <id>source4-5</id>
+ </hit>
+ <hit relevance="0.16666666666666666" source="source4">
+ <id>source4-6</id>
+ </hit>
+ </content>
</section>
</section>
-
-</result>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsResult.xml
index 623918c8739..0c29127da26 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsResult.xml
@@ -1,73 +1,78 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0" layout="column">
-
+<page version="1.0" layout="column">
<section layout="row">
<section id="section:box1">
- <hit relevance="1.0" source="source1">
- <id>source1-1</id>
- </hit>
- <hit relevance="0.5" source="source1">
- <id>source1-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source1">
- <id>source1-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source1">
+ <id>source1-1</id>
+ </hit>
+ <hit relevance="0.5" source="source1">
+ <id>source1-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source1">
+ <id>source1-3</id>
+ </hit>
+ </content>
</section>
<section id="section:box2">
- <hit relevance="1.0" source="source2">
- <id>source2-1</id>
- </hit>
- <hit relevance="0.5" source="source2">
- <id>source2-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source2">
- <id>source2-3</id>
- </hit>
- <hit relevance="0.25" source="source2">
- <id>source2-4</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source2">
+ <id>source2-1</id>
+ </hit>
+ <hit relevance="0.5" source="source2">
+ <id>source2-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source2">
+ <id>source2-3</id>
+ </hit>
+ <hit relevance="0.25" source="source2">
+ <id>source2-4</id>
+ </hit>
+ </content>
</section>
</section>
-
<section layout="row">
<section id="section:box3">
- <hit relevance="1.0" source="source3">
- <id>source3-1</id>
- </hit>
- <hit relevance="0.5" source="source3">
- <id>source3-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source3">
- <id>source3-3</id>
- </hit>
- <hit relevance="0.25" source="source3">
- <id>source3-4</id>
- </hit>
- <hit relevance="0.2" source="source3">
- <id>source3-5</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source3">
+ <id>source3-1</id>
+ </hit>
+ <hit relevance="0.5" source="source3">
+ <id>source3-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source3">
+ <id>source3-3</id>
+ </hit>
+ <hit relevance="0.25" source="source3">
+ <id>source3-4</id>
+ </hit>
+ <hit relevance="0.2" source="source3">
+ <id>source3-5</id>
+ </hit>
+ </content>
</section>
<section id="section:box4">
- <hit relevance="1.0" source="source4">
- <id>source4-1</id>
- </hit>
- <hit relevance="0.5" source="source4">
- <id>source4-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source4">
- <id>source4-3</id>
- </hit>
- <hit relevance="0.25" source="source4">
- <id>source4-4</id>
- </hit>
- <hit relevance="0.2" source="source4">
- <id>source4-5</id>
- </hit>
- <hit relevance="0.16666666666666666" source="source4">
- <id>source4-6</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source4">
+ <id>source4-1</id>
+ </hit>
+ <hit relevance="0.5" source="source4">
+ <id>source4-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source4">
+ <id>source4-3</id>
+ </hit>
+ <hit relevance="0.25" source="source4">
+ <id>source4-4</id>
+ </hit>
+ <hit relevance="0.2" source="source4">
+ <id>source4-5</id>
+ </hit>
+ <hit relevance="0.16666666666666666" source="source4">
+ <id>source4-6</id>
+ </hit>
+ </content>
</section>
</section>
-
-</result>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageResult.xml
index 1ac4368d3ec..29c6f47765c 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageResult.xml
@@ -1,16 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<page version="1.0">
-
<renderer name="two-column"/>
-
<section region="left">
<source url="http://carmot.yahoo.com:4080/resource/[news article id]"/>
<renderer name="articleBodyRenderer">
<parameter name="color">blue</parameter>
</renderer>
</section>
-
<section region="right">
<renderer name="multi-item-column">
<parameter name="items">3</parameter>
@@ -39,5 +36,4 @@
</content>
</section>
</section>
-
</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java
index a09088c3410..1935ad95c40 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.pagetemplates.engine.test;
-import com.yahoo.prelude.templates.PageTemplateSet;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.pagetemplates.engine.Organizer;
@@ -21,24 +20,24 @@ public class PageTestCase extends ExecutionAbstractTestCase {
@Test
public void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("Page.xml"));
+ Choice page = Choice.createSingleton(importPage("Page.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("news",2));
- result.hits().add(createHits("htmlSource",1));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("news", 2));
+ result.hits().add(createHits("htmlSource", 1));
// Resolve (noop here)
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page, query, result);
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check rendering
- assertRendered(result,"PageResult.xml",new PageTemplateSet());
+ assertRendered(result, "PageResult.xml");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingResult.xml
index 01f74ad67a2..e7e7a37715c 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingResult.xml
@@ -1,16 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<page version="1.0">
-
<renderer name="two-column"/>
-
<section region="left">
<source url="http://carmot.yahoo.com:4080/resource/[news article id]"/>
<renderer name="articleBodyRenderer">
<parameter name="color">blue</parameter>
</renderer>
</section>
-
<section region="right">
<renderer name="multi-item-column">
<parameter name="items">3</parameter>
@@ -41,5 +38,4 @@
</content>
</section>
</section>
-
</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java
index 0e8088d8b2a..5c8d756a72d 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.pagetemplates.engine.test;
-import com.yahoo.prelude.templates.PageTemplateSet;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.pagetemplates.engine.Organizer;
@@ -12,7 +11,7 @@ import com.yahoo.search.pagetemplates.model.Choice;
import org.junit.Test;
/**
- * Tests an exapnded example.
+ * Tests an expanded example.
*
* @author bratseth
*/
@@ -21,24 +20,24 @@ public class PageWithBlendingTestCase extends ExecutionAbstractTestCase {
@Test
public void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("PageWithBlending.xml"));
+ Choice page = Choice.createSingleton(importPage("PageWithBlending.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("news",2));
- result.hits().add(createHits("htmlSource",1));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("news", 2));
+ result.hits().add(createHits("htmlSource", 1));
// Resolve (noop here)
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page, query, result);
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check rendering
- assertRendered(result,"PageWithBlendingResult.xml",new PageTemplateSet());
+ assertRendered(result, "PageWithBlendingResult.xml");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererResult.xml
index 95f01a6d7c8..9dd3610c136 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererResult.xml
@@ -1,16 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<page version="1.0">
-
<renderer name="two-column"/>
-
<section region="left">
<source url="http://carmot.yahoo.com:4080/resource/[news article id]"/>
<renderer name="articleBodyRenderer">
<parameter name="color">blue</parameter>
</renderer>
</section>
-
<section region="right">
<renderer name="multi-item-column">
<parameter name="items">3</parameter>
@@ -39,5 +36,4 @@
</content>
</section>
</section>
-
</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java
index 4a9ad9745cf..35cc129ba93 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.pagetemplates.engine.test;
-import com.yahoo.prelude.templates.PageTemplateSet;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.pagetemplates.engine.Organizer;
@@ -21,24 +20,24 @@ public class PageWithSourceRendererTestCase extends ExecutionAbstractTestCase {
@Test
public void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("PageWithSourceRenderer.xml"));
+ Choice page = Choice.createSingleton(importPage("PageWithSourceRenderer.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("news",2));
- result.hits().add(createHits("htmlSource",1));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("news", 2));
+ result.hits().add(createHits("htmlSource", 1));
// Resolve
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page, query, result);
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check rendering
- assertRendered(result,"PageWithSourceRendererResult.xml",new PageTemplateSet());
+ assertRendered(result, "PageWithSourceRendererResult.xml");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceResult.xml
index dfdbac4b7ce..2c7bdff75fb 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceResult.xml
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<page version="1.0">
-
<content>
<hit relevance="1.0" source="web">
<id>web-1</id>
@@ -13,5 +12,4 @@
<id>web-3</id>
</hit>
</content>
-
</page>
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java
index 5c6cbbb4e27..93b6a958657 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.pagetemplates.engine.test;
-import com.yahoo.prelude.templates.PageTemplateSet;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.pagetemplates.engine.Organizer;
@@ -19,25 +18,25 @@ public class SourceChoiceTestCase extends ExecutionAbstractTestCase {
@Test
public void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("SourceChoice.xml"));
+ Choice page = Choice.createSingleton(importPage("SourceChoice.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("web",3));
- result.hits().add(createHits("news",3));
- result.hits().add(createHits("blog",3));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("web", 3));
+ result.hits().add(createHits("news", 3));
+ result.hits().add(createHits("blog", 3));
// Resolve (noop here)
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page,query,result);
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check rendering
- assertRendered(result,"SourceChoiceResult.xml",new PageTemplateSet(),true);
+ assertRendered(result,"SourceChoiceResult.xml", false);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesResult.xml b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesResult.xml
index 73b62afd6c1..0b0fe91e7b4 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesResult.xml
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesResult.xml
@@ -1,65 +1,66 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<result version="1.0" layout="twoColumns">
-
+<page version="1.0" layout="twoColumns">
<section region="left">
- <hit relevance="1.0" source="source3">
- <id>source3-1</id>
- </hit>
- <hit relevance="0.5" source="source3">
- <id>source3-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source3">
- <id>source3-3</id>
- </hit>
- <hit relevance="0.25" source="source3">
- <id>source3-4</id>
- </hit>
- <hit relevance="0.2" source="source3">
- <id>source3-5</id>
- </hit>
- <hit relevance="1.0" source="source1">
- <id>source1-1</id>
- </hit>
- <hit relevance="0.5" source="source1">
- <id>source1-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source1">
- <id>source1-3</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source3">
+ <id>source3-1</id>
+ </hit>
+ <hit relevance="0.5" source="source3">
+ <id>source3-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source3">
+ <id>source3-3</id>
+ </hit>
+ <hit relevance="0.25" source="source3">
+ <id>source3-4</id>
+ </hit>
+ <hit relevance="0.2" source="source3">
+ <id>source3-5</id>
+ </hit>
+ <hit relevance="1.0" source="source1">
+ <id>source1-1</id>
+ </hit>
+ <hit relevance="0.5" source="source1">
+ <id>source1-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source1">
+ <id>source1-3</id>
+ </hit>
+ </content>
</section>
-
<section region="right">
- <hit relevance="1.0" source="source4">
- <id>source4-1</id>
- </hit>
- <hit relevance="1.0" source="source2">
- <id>source2-1</id>
- </hit>
- <hit relevance="0.5" source="source4">
- <id>source4-2</id>
- </hit>
- <hit relevance="0.5" source="source2">
- <id>source2-2</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source4">
- <id>source4-3</id>
- </hit>
- <hit relevance="0.3333333333333333" source="source2">
- <id>source2-3</id>
- </hit>
- <hit relevance="0.25" source="source4">
- <id>source4-4</id>
- </hit>
- <hit relevance="0.25" source="source2">
- <id>source2-4</id>
- </hit>
- <hit relevance="0.2" source="source4">
- <id>source4-5</id>
- </hit>
- <hit relevance="0.16666666666666666" source="source4">
- <id>source4-6</id>
- </hit>
+ <content>
+ <hit relevance="1.0" source="source4">
+ <id>source4-1</id>
+ </hit>
+ <hit relevance="1.0" source="source2">
+ <id>source2-1</id>
+ </hit>
+ <hit relevance="0.5" source="source4">
+ <id>source4-2</id>
+ </hit>
+ <hit relevance="0.5" source="source2">
+ <id>source2-2</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source4">
+ <id>source4-3</id>
+ </hit>
+ <hit relevance="0.3333333333333333" source="source2">
+ <id>source2-3</id>
+ </hit>
+ <hit relevance="0.25" source="source4">
+ <id>source4-4</id>
+ </hit>
+ <hit relevance="0.25" source="source2">
+ <id>source2-4</id>
+ </hit>
+ <hit relevance="0.2" source="source4">
+ <id>source4-5</id>
+ </hit>
+ <hit relevance="0.16666666666666666" source="source4">
+ <id>source4-6</id>
+ </hit>
+ </content>
</section>
-
-</result>
+</page>
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java
index 4b2da823271..663fe004b43 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java
@@ -5,8 +5,11 @@ package com.yahoo.search.querytransform;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.SameElementItem;
import org.junit.After;
import org.junit.Before;
@@ -31,19 +34,16 @@ import com.yahoo.search.searchchain.Execution;
/**
* Tests term lowercasing in the search chain.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class LowercasingTestCase {
private static final String TEDDY = "teddy";
private static final String BAMSE = "bamse";
private static final String SARR = "sarr";
- IndexFacts settings;
- Execution execution;
- @Before
- public void setUp() throws Exception {
- IndexFacts f = new IndexFacts();
+ private IndexFacts createIndexFacts() {
+ SearchDefinition sd = new SearchDefinition("nalle");
Index bamse = new Index(BAMSE);
Index teddy = new Index(TEDDY);
Index sarrBamse = new Index(SARR + "." + BAMSE);
@@ -54,25 +54,22 @@ public class LowercasingTestCase {
sarrBamse.setLowercase(true);
sarrTeddy.setLowercase(true);
defaultIndex.setLowercase(true);
- f.addIndex("nalle", bamse);
- f.addIndex("nalle", teddy);
- f.addIndex("nalle", defaultIndex);
- f.addIndex("nalle", sarrBamse);
- f.addIndex("nalle", sarrTeddy);
- f.freeze();
- settings = f;
- execution = new Execution(new Chain<Searcher>(
- new VespaLowercasingSearcher(new LowercasingConfig(new LowercasingConfig.Builder()))),
- Execution.Context.createContextStub(settings));
+ sd.addIndex(bamse);
+ sd.addIndex(teddy);
+ sd.addIndex(defaultIndex);
+ sd.addIndex(sarrBamse);
+ sd.addIndex(sarrTeddy);
+ return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
}
- @After
- public void tearDown() throws Exception {
- execution = null;
+ private Execution createExecution() {
+ return new Execution(new Chain<Searcher>(
+ new VespaLowercasingSearcher(new LowercasingConfig(new LowercasingConfig.Builder()))),
+ Execution.Context.createContextStub(createIndexFacts()));
}
@Test
- public void smoke() {
+ public void simple() {
Query q = new Query();
AndItem root = new AndItem();
WordItem tmp;
@@ -84,7 +81,7 @@ public class LowercasingTestCase {
root.addItem(tmp);
q.getModel().getQueryTree().setRoot(root);
- Result r = execution.search(q);
+ Result r = createExecution().search(q);
root = (AndItem) r.getQuery().getModel().getQueryTree().getRoot();
WordItem w0 = (WordItem) root.getItem(0);
WordItem w1 = (WordItem) root.getItem(1);
@@ -129,7 +126,7 @@ public class LowercasingTestCase {
q.getModel().getQueryTree().setRoot(a0);
- Result r = execution.search(q);
+ Result r = createExecution().search(q);
AndItem root = (AndItem) r.getQuery().getModel().getQueryTree().getRoot();
tmp = (WordItem) root.getItem(0);
assertEquals("nalle0", tmp.getWord());
@@ -162,7 +159,7 @@ public class LowercasingTestCase {
tmp.addToken("dEf", 5);
root.addItem(tmp);
q.getModel().getQueryTree().setRoot(root);
- Result r = execution.search(q);
+ Result r = createExecution().search(q);
root = (AndItem) r.getQuery().getModel().getQueryTree().getRoot();
WeightedSetItem w0 = (WeightedSetItem) root.getItem(0);
WeightedSetItem w1 = (WeightedSetItem) root.getItem(1);
@@ -174,11 +171,11 @@ public class LowercasingTestCase {
@Test
public void testDisableLowercasingWeightedSet() {
- execution = new Execution(new Chain<Searcher>(
+ Execution execution = new Execution(new Chain<Searcher>(
new VespaLowercasingSearcher(new LowercasingConfig(
new LowercasingConfig.Builder()
.transform_weighted_sets(false)))),
- Execution.Context.createContextStub(settings));
+ Execution.Context.createContextStub(createIndexFacts()));
Query q = new Query();
AndItem root = new AndItem();
@@ -202,8 +199,8 @@ public class LowercasingTestCase {
@Test
public void testLowercasingWordAlternatives() {
- execution = new Execution(new Chain<Searcher>(new VespaLowercasingSearcher(new LowercasingConfig(
- new LowercasingConfig.Builder().transform_weighted_sets(false)))), Execution.Context.createContextStub(settings));
+ Execution execution = new Execution(new Chain<Searcher>(new VespaLowercasingSearcher(new LowercasingConfig(
+ new LowercasingConfig.Builder().transform_weighted_sets(false)))), Execution.Context.createContextStub(createIndexFacts()));
Query q = new Query();
WordAlternativesItem root;
@@ -224,17 +221,18 @@ public class LowercasingTestCase {
}
@Test
- public void testLowercaseingSameElement() {
+ public void testLowercasingSameElement() {
Query q = new Query();
SameElementItem root = new SameElementItem(SARR);
root.addItem(new WordItem("ABC", BAMSE, true));
root.addItem(new WordItem("DEF", TEDDY, true));
q.getModel().getQueryTree().setRoot(root);
- Result r = execution.search(q);
+ Result r = createExecution().search(q);
root = (SameElementItem) r.getQuery().getModel().getQueryTree().getRoot();
WordItem w0 = (WordItem) root.getItem(0);
WordItem w1 = (WordItem) root.getItem(1);
assertEquals("abc", w0.getWord());
assertEquals("def", w1.getWord());
}
+
}
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java
index 93955da383e..c52cedaaf0e 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java
@@ -4,6 +4,8 @@ package com.yahoo.search.querytransform;
import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.DotProductItem;
import com.yahoo.prelude.query.Item;
@@ -20,6 +22,7 @@ import com.yahoo.search.searchchain.Execution;
import org.junit.Before;
import org.junit.Test;
+import java.util.Collections;
import java.util.ListIterator;
import static com.yahoo.container.protect.Error.INVALID_QUERY_PARAMETER;
@@ -40,10 +43,9 @@ public class WandSearcherTestCase {
@SuppressWarnings("deprecation")
private IndexFacts buildIndexFacts() {
- IndexFacts retval = new IndexFacts();
- retval.addIndex("test", new Index(VESPA_FIELD));
- retval.freeze();
- return retval;
+ SearchDefinition sd = new SearchDefinition("test");
+ sd.addIndex(new Index(VESPA_FIELD));
+ return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
}
private Execution buildExec() {
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
index a3f7ff12319..60abac599c4 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
@@ -2,15 +2,19 @@
package com.yahoo.search.querytransform.test;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import com.google.common.collect.ImmutableList;
import com.yahoo.component.chain.Chain;
import com.yahoo.language.Language;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.hitfield.JSONString;
import com.yahoo.prelude.hitfield.XMLString;
import com.yahoo.prelude.query.AndItem;
@@ -28,7 +32,6 @@ import com.yahoo.search.querytransform.NGramSearcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Before;
import org.junit.Test;
import static com.yahoo.search.searchchain.Execution.Context.createContextStub;
@@ -41,157 +44,151 @@ import static org.junit.Assert.assertTrue;
*/
public class NGramSearcherTestCase {
- private Searcher searcher;
- private IndexFacts indexFacts;
-
- @Before
- public void setUp() {
- searcher = new NGramSearcher(new SimpleLinguistics());
- indexFacts = new IndexFacts();
+ public IndexFacts createIndexFacts() {
+ SearchDefinition sd = new SearchDefinition("default");
Index defaultIndex = new Index("default");
defaultIndex.setNGram(true, 3);
defaultIndex.setDynamicSummary(true);
- indexFacts.addIndex("default", defaultIndex);
+ sd.addIndex(defaultIndex);
Index test = new Index("test");
test.setHighlightSummary(true);
- indexFacts.addIndex("default", test);
+ sd.addIndex(test);
Index gram2 = new Index("gram2");
gram2.setNGram(true, 2);
gram2.setDynamicSummary(true);
- indexFacts.addIndex("default", gram2);
+ sd.addIndex(gram2);
Index gram3 = new Index("gram3");
gram3.setNGram(true, 3);
gram3.setHighlightSummary(true);
- indexFacts.addIndex("default", gram3);
+ sd.addIndex(gram3);
Index gram14 = new Index("gram14");
gram14.setNGram(true, 14);
gram14.setDynamicSummary(true);
- indexFacts.addIndex("default", gram14);
+ sd.addIndex(gram14);
+
+ return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
+ }
+
+ private Searcher createSearcher() {
+ return new NGramSearcher(new SimpleLinguistics());
}
- private IndexFacts getMixedSetup() {
- IndexFacts indexFacts = new IndexFacts();
- String musicDoctype = "music";
- String songDoctype = "song";
+ public Execution createExecution() {
+ return new Execution(createSearcher(), Execution.Context.createContextStub(createIndexFacts()));
+ }
+
+ private Execution createMixedSetupExecution() {
+ SearchDefinition music = new SearchDefinition("music");
Index musicDefault = new Index("default");
- musicDefault.setNGram(true, 1);
- indexFacts.addIndex(musicDoctype, musicDefault);
+ musicDefault.addCommand("ngram 1");
+ music.addIndex(musicDefault);
+
+ SearchDefinition song = new SearchDefinition("song");
Index songDefault = new Index("default");
- indexFacts.addIndex(songDoctype, songDefault);
+ song.addIndex(songDefault);
+
Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("musicOnly", Arrays.asList(new String[] { musicDoctype }));
- clusters.put("songOnly", Arrays.asList(new String[] { songDoctype }));
- clusters.put("musicAndSong", Arrays.asList(new String[] { musicDoctype, songDoctype }));
- indexFacts.setClusters(clusters);
- return indexFacts;
+ clusters.put("musicOnly", Collections.singletonList(music.getName()));
+ clusters.put("songOnly", Collections.singletonList(song.getName()));
+ clusters.put("musicAndSong", Arrays.asList(music.getName(), song.getName()));
+
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, ImmutableList.of(music, song)));
+ return new Execution(createSearcher(), Execution.Context.createContextStub(indexFacts));
}
@Test
public void testMixedDocTypes() {
- final IndexFacts mixedSetup = getMixedSetup();
{
Query q = new Query("?query=abc&restrict=song");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("abc", q.getModel().getQueryTree().toString());
}
{
Query q = new Query("?query=abc&restrict=music");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
- assertEquals("AND a b c", q.getModel().getQueryTree().toString());
- }
- {
- Query q = new Query("?query=abc");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("AND a b c", q.getModel().getQueryTree().toString());
}
{
Query q = new Query("?query=abc&search=song");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("abc", q.getModel().getQueryTree().toString());
}
{
Query q = new Query("?query=abc&search=music");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("AND a b c", q.getModel().getQueryTree().toString());
}
}
@Test
public void testMixedClusters() {
- final IndexFacts mixedSetup = getMixedSetup();
{
Query q = new Query("?query=abc&search=songOnly");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("abc", q.getModel().getQueryTree().toString());
}
{
Query q = new Query("?query=abc&search=musicOnly");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("AND a b c", q.getModel().getQueryTree().toString());
}
{
Query q = new Query("?query=abc&search=musicAndSong&restrict=music");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("AND a b c", q.getModel().getQueryTree().toString());
}
{
Query q = new Query("?query=abc&search=musicAndSong&restrict=song");
- new Execution(searcher, Execution.Context.createContextStub(mixedSetup)).search(q);
+ createMixedSetupExecution().search(q);
assertEquals("abc", q.getModel().getQueryTree().toString());
}
}
@Test
- public void testClusterMappingWithMixedDoctypes() {
- final IndexFacts mixedSetup = getMixedSetup();
-
- }
-
- @Test
public void testNGramRewritingMixedQuery() {
- Query q=new Query("?query=foo+gram3:engul+test:bar");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("AND foo (AND gram3:eng gram3:ngu gram3:gul) test:bar",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=foo+gram3:engul+test:bar");
+ createExecution().search(q);
+ assertEquals("AND foo (AND gram3:eng gram3:ngu gram3:gul) test:bar", q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRewritingNGramOnly() {
- Query q=new Query("?query=gram3:engul");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("AND gram3:eng gram3:ngu gram3:gul",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=gram3:engul");
+ createExecution().search(q);
+ assertEquals("AND gram3:eng gram3:ngu gram3:gul", q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRewriting2NGramsOnly() {
- Query q=new Query("?query=gram3:engul+gram2:123");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("AND (AND gram3:eng gram3:ngu gram3:gul) (AND gram2:12 gram2:23)",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=gram3:engul+gram2:123");
+ createExecution().search(q);
+ assertEquals("AND (AND gram3:eng gram3:ngu gram3:gul) (AND gram2:12 gram2:23)", q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRewritingShortOnly() {
- Query q=new Query("?query=gram3:en");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("gram3:en",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=gram3:en");
+ createExecution().search(q);
+ assertEquals("gram3:en", q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRewritingShortInMixes() {
- Query q=new Query("?query=test:a+gram3:en");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("AND test:a gram3:en",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=test:a+gram3:en");
+ createExecution().search(q);
+ assertEquals("AND test:a gram3:en", q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRewritingPhrase() {
- Query q=new Query("?query=gram3:%22engul+a+holi%22");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("gram3:\"eng ngu gul a hol oli\"",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=gram3:%22engul+a+holi%22");
+ createExecution().search(q);
+ assertEquals("gram3:\"eng ngu gul a hol oli\"", q.getModel().getQueryTree().toString());
}
/**
@@ -200,159 +197,169 @@ public class NGramSearcherTestCase {
*/
@Test
public void testNGramRewritingPhraseSingleTerm() {
- Query q=new Query("?query=gram3:%22engul%22");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("AND gram3:eng gram3:ngu gram3:gul",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=gram3:%22engul%22");
+ createExecution().search(q);
+ assertEquals("AND gram3:eng gram3:ngu gram3:gul", q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRewritingAdditionalTermInfo() {
- Query q=new Query("?query=gram3:engul!50+foo+gram2:123!150");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- AndItem root=(AndItem)q.getModel().getQueryTree().getRoot();
- AndItem gram3And=(AndItem)root.getItem(0);
- AndItem gram2And=(AndItem)root.getItem(2);
-
- assertExtraTermInfo(50,"engul",gram3And.getItem(0));
- assertExtraTermInfo(50,"engul",gram3And.getItem(1));
- assertExtraTermInfo(50,"engul",gram3And.getItem(2));
- assertExtraTermInfo(150,"123",gram2And.getItem(0));
- assertExtraTermInfo(150,"123",gram2And.getItem(1));
+ Query q = new Query("?query=gram3:engul!50+foo+gram2:123!150");
+ createExecution().search(q);
+ AndItem root = (AndItem)q.getModel().getQueryTree().getRoot();
+ AndItem gram3And = (AndItem)root.getItem(0);
+ AndItem gram2And = (AndItem)root.getItem(2);
+
+ assertExtraTermInfo(50, "engul", gram3And.getItem(0));
+ assertExtraTermInfo(50, "engul", gram3And.getItem(1));
+ assertExtraTermInfo(50, "engul", gram3And.getItem(2));
+ assertExtraTermInfo(150, "123", gram2And.getItem(0));
+ assertExtraTermInfo(150, "123", gram2And.getItem(1));
}
- private void assertExtraTermInfo(int weight,String origin, Item g) {
- WordItem gram=(WordItem)g;
- assertEquals(weight,gram.getWeight());
- assertEquals(origin,gram.getOrigin().getValue());
+ private void assertExtraTermInfo(int weight, String origin, Item g) {
+ WordItem gram = (WordItem)g;
+ assertEquals(weight, gram.getWeight());
+ assertEquals(origin, gram.getOrigin().getValue());
assertTrue(gram.isProtected());
assertFalse(gram.isFromQuery());
}
@Test
public void testNGramRewritingExplicitDefault() {
- Query q=new Query("?query=default:engul");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("AND default:eng default:ngu default:gul",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=default:engul");
+ createExecution().search(q);
+ assertEquals("AND default:eng default:ngu default:gul" ,q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRewritingImplicitDefault() {
- Query q=new Query("?query=engul");
- new Execution(searcher,Execution.Context.createContextStub(indexFacts)).search(q);
- assertEquals("AND eng ngu gul",q.getModel().getQueryTree().toString());
+ Query q = new Query("?query=engul");
+ createExecution().search(q);
+ assertEquals("AND eng ngu gul", q.getModel().getQueryTree().toString());
}
@Test
public void testGramsWithSegmentation() {
+ Searcher searcher = createSearcher();
assertGramsWithSegmentation(new Chain<>(searcher));
- assertGramsWithSegmentation(new Chain<>(new CJKSearcher(),searcher));
- assertGramsWithSegmentation(new Chain<>(searcher,new CJKSearcher()));
+ assertGramsWithSegmentation(new Chain<>(new CJKSearcher(), searcher));
+ assertGramsWithSegmentation(new Chain<>(searcher, new CJKSearcher()));
}
public void assertGramsWithSegmentation(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("gram14:firstsecondthird", Query.Type.ANY);
- Query q=new Query("?query=ignored");
+ Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
- new Execution(chain,createContextStub(indexFacts)).search(q);
- assertEquals("AND gram14:firstsecondthi gram14:irstsecondthir gram14:rstsecondthird",q.getModel().getQueryTree().toString());
+ new Execution(chain, createContextStub(createIndexFacts())).search(q);
+ assertEquals("AND gram14:firstsecondthi gram14:irstsecondthir gram14:rstsecondthird", q.getModel().getQueryTree().toString());
}
@Test
public void testGramsWithSegmentationSingleSegment() {
+ Searcher searcher = createSearcher();
assertGramsWithSegmentationSingleSegment(new Chain<>(searcher));
- assertGramsWithSegmentationSingleSegment(new Chain<>(new CJKSearcher(),searcher));
- assertGramsWithSegmentationSingleSegment(new Chain<>(searcher,new CJKSearcher()));
+ assertGramsWithSegmentationSingleSegment(new Chain<>(new CJKSearcher(), searcher));
+ assertGramsWithSegmentationSingleSegment(new Chain<>(searcher, new CJKSearcher()));
}
public void assertGramsWithSegmentationSingleSegment(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("gram14:first", Query.Type.ANY);
- Query q=new Query("?query=ignored");
+ Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
- new Execution(chain,createContextStub(indexFacts)).search(q);
- assertEquals("gram14:first",q.getModel().getQueryTree().toString());
+ new Execution(chain, createContextStub(createIndexFacts())).search(q);
+ assertEquals("gram14:first", q.getModel().getQueryTree().toString());
}
@Test
public void testGramsWithSegmentationSubstringSegmented() {
+ Searcher searcher = createSearcher();
assertGramsWithSegmentationSubstringSegmented(new Chain<>(searcher));
- assertGramsWithSegmentationSubstringSegmented(new Chain<>(new CJKSearcher(),searcher));
- assertGramsWithSegmentationSubstringSegmented(new Chain<>(searcher,new CJKSearcher()));
+ assertGramsWithSegmentationSubstringSegmented(new Chain<>(new CJKSearcher(), searcher));
+ assertGramsWithSegmentationSubstringSegmented(new Chain<>(searcher, new CJKSearcher()));
}
public void assertGramsWithSegmentationSubstringSegmented(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("gram14:afirstsecondthirdo", Query.Type.ANY);
- Query q=new Query("?query=ignored");
+ Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
- new Execution(chain,createContextStub(indexFacts)).search(q);
- assertEquals("AND gram14:afirstsecondth gram14:firstsecondthi gram14:irstsecondthir gram14:rstsecondthird gram14:stsecondthirdo",q.getModel().getQueryTree().toString());
+ new Execution(chain, createContextStub(createIndexFacts())).search(q);
+ assertEquals("AND gram14:afirstsecondth gram14:firstsecondthi gram14:irstsecondthir gram14:rstsecondthird gram14:stsecondthirdo",
+ q.getModel().getQueryTree().toString());
}
@Test
public void testGramsWithSegmentationMixed() {
+ Searcher searcher = createSearcher();
assertGramsWithSegmentationMixed(new Chain<>(searcher));
- assertGramsWithSegmentationMixed(new Chain<>(new CJKSearcher(),searcher));
- assertGramsWithSegmentationMixed(new Chain<>(searcher,new CJKSearcher()));
+ assertGramsWithSegmentationMixed(new Chain<>(new CJKSearcher(), searcher));
+ assertGramsWithSegmentationMixed(new Chain<>(searcher, new CJKSearcher()));
}
public void assertGramsWithSegmentationMixed(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("a gram14:afirstsecondthird b gram14:hi", Query.Type.ALL);
- Query q=new Query("?query=ignored");
+ Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
- new Execution(chain,createContextStub(indexFacts)).search(q);
- assertEquals("AND a (AND gram14:afirstsecondth gram14:firstsecondthi gram14:irstsecondthir gram14:rstsecondthird) b gram14:hi",q.getModel().getQueryTree().toString());
+ new Execution(chain, createContextStub(createIndexFacts())).search(q);
+ assertEquals("AND a (AND gram14:afirstsecondth gram14:firstsecondthi gram14:irstsecondthir gram14:rstsecondthird) b gram14:hi",
+ q.getModel().getQueryTree().toString());
}
@Test
public void testGramsWithSegmentationMixedAndPhrases() {
+ Searcher searcher = createSearcher();
assertGramsWithSegmentationMixedAndPhrases(new Chain<>(searcher));
- assertGramsWithSegmentationMixedAndPhrases(new Chain<>(new CJKSearcher(),searcher));
- assertGramsWithSegmentationMixedAndPhrases(new Chain<>(searcher,new CJKSearcher()));
+ assertGramsWithSegmentationMixedAndPhrases(new Chain<>(new CJKSearcher(), searcher));
+ assertGramsWithSegmentationMixedAndPhrases(new Chain<>(searcher, new CJKSearcher()));
}
public void assertGramsWithSegmentationMixedAndPhrases(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("a gram14:\"afirstsecondthird b hi\"", Query.Type.ALL);
- Query q=new Query("?query=ignored");
+ Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
- new Execution(chain,createContextStub(indexFacts)).search(q);
- assertEquals("AND a gram14:\"afirstsecondth firstsecondthi irstsecondthir rstsecondthird b hi\"",q.getModel().getQueryTree().toString());
+ new Execution(chain, createContextStub(createIndexFacts())).search(q);
+ assertEquals("AND a gram14:\"afirstsecondth firstsecondthi irstsecondthir rstsecondthird b hi\"",
+ q.getModel().getQueryTree().toString());
}
@Test
public void testNGramRecombining() {
- Query q=new Query("?query=ignored");
- Result r=new Execution(new Chain<>(searcher,new MockBackend1()),createContextStub(indexFacts)).search(q);
- Hit h1=r.hits().get("hit1");
- assertEquals("Should be untouched,\u001feven if containing \u001f",h1.getField("test").toString());
+ Query q = new Query("?query=ignored");
+ Result r = new Execution(new Chain<>(createSearcher(), new MockBackend1()), createContextStub(createIndexFacts())).search(q);
+ Hit h1 = r.hits().get("hit1");
+ assertEquals("Should be untouched,\u001feven if containing \u001f",
+ h1.getField("test").toString());
assertTrue(h1.getField("test") instanceof String);
assertEquals("Blue red Ed A",h1.getField("gram2").toString());
assertTrue(h1.getField("gram2") instanceof XMLString);
- assertEquals("Separators on borders work","Blue red ed a\u001f",h1.getField("gram3").toString());
+ assertEquals("Separators on borders work","Blue red ed a\u001f",
+ h1.getField("gram3").toString());
assertTrue(h1.getField("gram3") instanceof String);
- Hit h2=r.hits().get("hit2");
- assertEquals("katt i...morgen",h2.getField("gram3").toString());
+ Hit h2 = r.hits().get("hit2");
+ assertEquals("katt i...morgen", h2.getField("gram3").toString());
assertTrue(h2.getField("gram3") instanceof JSONString);
- Hit h3=r.hits().get("hit3");
- assertEquals("\u001ffin\u001f \u001fen\u001f \u001fa\u001f",h3.getField("gram2").toString());
+ Hit h3 = r.hits().get("hit3");
+ assertEquals("\u001ffin\u001f \u001fen\u001f \u001fa\u001f", h3.getField("gram2").toString());
assertEquals("#Logging in #Java is like that \"Judean P\u001fopul\u001far Front\" scene from \"Life of Brian\".",
h3.getField("gram3").toString());
}
private Item parseQuery(String query, Query.Type type) {
- Parser parser = ParserFactory.newInstance(type, new ParserEnvironment().setIndexFacts(indexFacts));
+ Parser parser = ParserFactory.newInstance(type, new ParserEnvironment().setIndexFacts(createIndexFacts()));
return parser.parse(new Parsable().setQuery(query).setLanguage(Language.UNKNOWN)).getRoot();
}
@@ -360,31 +367,32 @@ public class NGramSearcherTestCase {
@Override
public Result search(Query query, Execution execution) {
- Result r=new Result(query);
- HitGroup g=new HitGroup();
+ Result r = new Result(query);
+ HitGroup g = new HitGroup();
r.hits().add(g);
- Hit h1=new Hit("hit1");
- h1.setField(Hit.SDDOCNAME_FIELD,"default");
- h1.setField("test","Should be untouched,\u001feven if containing \u001f");
- h1.setField("gram2",new XMLString("\uFFF9Bl\uFFFAbl\uFFFBluue reed \uFFF9Ed\uFFFAed\uFFFB \uFFF9A\uFFFAa\uFFFB"));
- h1.setField("gram3","\uFFF9Blu\uFFFAblu\uFFFBlue red ed a\u001f"); // separator on borders should not trip anything
+ Hit h1 = new Hit("hit1");
+ h1.setField(Hit.SDDOCNAME_FIELD, "default");
+ h1.setField("test", "Should be untouched,\u001feven if containing \u001f");
+ h1.setField("gram2", new XMLString("\uFFF9Bl\uFFFAbl\uFFFBluue reed \uFFF9Ed\uFFFAed\uFFFB \uFFF9A\uFFFAa\uFFFB"));
+ h1.setField("gram3", "\uFFF9Blu\uFFFAblu\uFFFBlue red ed a\u001f"); // separator on borders should not trip anything
g.add(h1);
- Hit h2=new Hit("hit2");
- h2.setField(Hit.SDDOCNAME_FIELD,"default");
- h2.setField("gram3",new JSONString("katatt i...mororgrgegen"));
+ Hit h2 = new Hit("hit2");
+ h2.setField(Hit.SDDOCNAME_FIELD, "default");
+ h2.setField("gram3", new JSONString("katatt i...mororgrgegen"));
r.hits().add(h2);
// Test bolding
- Hit h3=new Hit("hit3");
- h3.setField(Hit.SDDOCNAME_FIELD,"default");
+ Hit h3 = new Hit("hit3");
+ h3.setField(Hit.SDDOCNAME_FIELD, "default");
// the result of searching for "fin en a"
- h3.setField("gram2","\u001ffi\u001f\u001fin\u001f \u001fen\u001f \u001fa\u001f");
+ h3.setField("gram2", "\u001ffi\u001f\u001fin\u001f \u001fen\u001f \u001fa\u001f");
// the result from Juniper from of bolding the substring "opul":
- h3.setField("gram3","#Logoggggigining in #Javava is likike thahat \"Jududedeaean Pop\u001fopu\u001f\u001fpul\u001fulalar Froronont\" scecenene frorom \"Lifife of Bririaian\".");
+ h3.setField("gram3",
+ "#Logoggggigining in #Javava is likike thahat \"Jududedeaean Pop\u001fopu\u001f\u001fpul\u001fulalar Froronont\" scecenene frorom \"Lifife of Bririaian\".");
r.hits().add(h3);
return r;
}
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java
index 00bd87b4bf9..cb380b31030 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java
@@ -6,6 +6,8 @@ import com.yahoo.language.Linguistics;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.IntItem;
import com.yahoo.prelude.query.Item;
@@ -19,6 +21,7 @@ import com.yahoo.search.querytransform.RangeQueryOptimizer;
import com.yahoo.search.searchchain.Execution;
import org.junit.Test;
+import java.util.Collections;
import java.util.Iterator;
import static org.junit.Assert.*;
@@ -210,15 +213,15 @@ public class RangeQueryOptimizerTestCase {
}
private static IndexFacts createIndexFacts() {
- IndexFacts indexFacts = new IndexFacts();
+ SearchDefinition sd = new SearchDefinition("test");
Index singleValue1 = new Index("s");
Index singleValue2 = new Index("t");
Index multiValue = new Index("m");
multiValue.setMultivalue(true);
- indexFacts.addIndex("test", singleValue1);
- indexFacts.addIndex("test", singleValue2);
- indexFacts.addIndex("test", multiValue);
- return indexFacts;
+ sd.addIndex(singleValue1);
+ sd.addIndex(singleValue2);
+ sd.addIndex(multiValue);
+ return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java
index 5b0c2c7e5a3..243bacc73b3 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java
@@ -4,6 +4,8 @@ package com.yahoo.search.querytransform.test;
import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.QueryException;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
@@ -14,6 +16,8 @@ import com.yahoo.search.querytransform.SortingDegrader;
import com.yahoo.search.searchchain.Execution;
import org.junit.Test;
+import java.util.Collections;
+
import static org.junit.Assert.*;
/**
@@ -147,7 +151,7 @@ public class SortingDegraderTestCase {
}
private IndexFacts createIndexFacts() {
- IndexFacts indexFacts = new IndexFacts();
+ SearchDefinition test = new SearchDefinition("test");
Index fastSearchAttribute1 = new Index("a1");
fastSearchAttribute1.setFastSearch(true);
@@ -163,11 +167,11 @@ public class SortingDegraderTestCase {
Index stringAttribute = new Index("stringAttribute");
stringAttribute.setFastSearch(true);
- indexFacts.addIndex("test", fastSearchAttribute1);
- indexFacts.addIndex("test", fastSearchAttribute2);
- indexFacts.addIndex("test", nonFastSearchAttribute);
- indexFacts.addIndex("stringAttribute", stringAttribute);
- return indexFacts;
+ test.addIndex(fastSearchAttribute1);
+ test.addIndex(fastSearchAttribute2);
+ test.addIndex(nonFastSearchAttribute);
+ test.addIndex(stringAttribute);
+ return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(test)));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
index 726d5cb76be..5b3b5ca6d73 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
@@ -479,8 +479,8 @@ public class JsonRendererTestCase {
Execution.Context.createContextStub());
Result r = new Result(q);
execution.search(q);
- final TraceNode child = new TraceNode("string payload", 0L);
- final TraceNode childOfChild = new TraceNode(null, 0L);
+ TraceNode child = new TraceNode("string payload", 0L);
+ TraceNode childOfChild = new TraceNode(null, 0L);
child.add(childOfChild);
childOfChild.add(new TraceNode("in OO languages, nesting is for birds", 0L));
execution.trace().traceNode().add(child);
@@ -490,7 +490,7 @@ public class JsonRendererTestCase {
@Test
- public final void test() throws IOException, InterruptedException, ExecutionException, JSONException {
+ public final void test() throws IOException, InterruptedException, ExecutionException {
String expected = "{\n"
+ " \"root\": {\n"
+ " \"children\": [\n"
@@ -556,10 +556,9 @@ public class JsonRendererTestCase {
+ " }\n"
+ "}";
Query q = new Query("/?query=a&tracelevel=5&reportCoverage=true");
- Execution execution = new Execution(
- Execution.Context.createContextStub());
+ Execution execution = new Execution(Execution.Context.createContextStub());
Result r = new Result(q);
- r.setCoverage(new Coverage(500, 1, true));
+ r.setCoverage(new Coverage(500, 500,1,1));
FastHit h = new FastHit("http://localhost/", .95);
h.setField("$a", "Hello, world.");
@@ -593,7 +592,7 @@ public class JsonRendererTestCase {
+ " \"non-ideal-state\" : false"
+ " },\n"
+ " \"full\": false,\n"
- + " \"nodes\": 0,\n"
+ + " \"nodes\": 1,\n"
+ " \"results\": 1,\n"
+ " \"resultsFull\": 0\n"
+ " },\n"
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java
index 09d36bb3857..1d2187376a4 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java
@@ -30,7 +30,7 @@ import com.yahoo.text.Utf8;
/**
* Check the legacy sync default renderer doesn't spontaneously combust.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class SyncDefaultRendererTestCase {
@@ -58,11 +58,11 @@ public class SyncDefaultRendererTestCase {
@SuppressWarnings("deprecation")
@Test
- public final void testRenderWriterResult() throws IOException, InterruptedException, ExecutionException {
+ public final void testRenderWriterResult() throws InterruptedException, ExecutionException {
Query q = new Query("/?query=a&tracelevel=5&reportCoverage=true");
q.getPresentation().setTiming(true);
Result r = new Result(q);
- r.setCoverage(new Coverage(500, 1, true));
+ r.setCoverage(new Coverage(500, 1));
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -77,7 +77,6 @@ public class SyncDefaultRendererTestCase {
t.sampleSearchReturn(1, true, null);
t.sampleSearchReturn(0, true, null);
r.getElapsedTime().add(t);
- r.getTemplating().setRenderer(d);
FastHit h = new FastHit("http://localhost/", .95);
h.setField("$a", "Hello, world.");
h.setField("b", "foo");
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
index a52d9bcdb6c..c95019d37d6 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
@@ -31,7 +31,7 @@ import com.yahoo.text.Utf8;
/**
* Test the XML renderer
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class XMLRendererTestCase {
@@ -62,7 +62,7 @@ public class XMLRendererTestCase {
Query q = new Query("/?query=a&tracelevel=5&reportCoverage=true");
q.getPresentation().setTiming(true);
Result r = new Result(q);
- r.setCoverage(new Coverage(500, 1, true));
+ r.setCoverage(new Coverage(500, 1));
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -77,7 +77,6 @@ public class XMLRendererTestCase {
t.sampleSearchReturn(1, true, null);
t.sampleSearchReturn(0, true, null);
r.getElapsedTime().add(t);
- r.getTemplating().setRenderer(d);
FastHit h = new FastHit("http://localhost/", .95);
h.setField("$a", "Hello, world.");
h.setField("b", "foo");
diff --git a/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java b/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java
index 68399e6bfc4..7624185481e 100644
--- a/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java
@@ -16,7 +16,7 @@ public class CoverageTestCase {
@Test
public void testZeroCoverage() {
- Coverage c = new Coverage(0L, 0, false, 0);
+ Coverage c = new Coverage(0L, 0, 0, 0);
assertEquals(0, c.getResultPercentage());
assertEquals(0, c.getResultSets());
}
@@ -35,36 +35,36 @@ public class CoverageTestCase {
@Test
public void testDefaultCoverage() {
- boolean create=true;
+ boolean create = true;
- Result r1=new Result(new Query());
- assertEquals(0,r1.getCoverage(create).getResultSets());
- Result r2=new Result(new Query());
+ Result r1 = new Result(new Query());
+ assertEquals(0, r1.getCoverage(create).getResultSets());
+ Result r2 = new Result(new Query());
r1.mergeWith(r2);
- assertEquals(0,r1.getCoverage(create).getResultSets());
+ assertEquals(0, r1.getCoverage(create).getResultSets());
}
@Test
public void testDefaultSearchScenario() {
- boolean create=true;
+ boolean create = true;
- Result federationSearcherResult=new Result(new Query());
- Result singleSourceResult=new Result(new Query());
+ Result federationSearcherResult = new Result(new Query());
+ Result singleSourceResult = new Result(new Query());
federationSearcherResult.mergeWith(singleSourceResult);
- assertNull(federationSearcherResult.getCoverage(!create));
- assertEquals(0,federationSearcherResult.getCoverage(create).getResultSets());
+ assertNull(federationSearcherResult.getCoverage( !create));
+ assertEquals(0, federationSearcherResult.getCoverage(create).getResultSets());
}
@Test
public void testRequestingCoverageSearchScenario() {
- boolean create=true;
+ boolean create = true;
- Result federationSearcherResult=new Result(new Query());
- Result singleSourceResult=new Result(new Query());
- singleSourceResult.setCoverage(new Coverage(10,1,true));
+ Result federationSearcherResult = new Result(new Query());
+ Result singleSourceResult = new Result(new Query());
+ singleSourceResult.setCoverage(new Coverage(10, 1));
federationSearcherResult.mergeWith(singleSourceResult);
- assertEquals(1,federationSearcherResult.getCoverage(create).getResultSets());
+ assertEquals(1, federationSearcherResult.getCoverage(create).getResultSets());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/result/test/DefaultErrorHitTestCase.java b/container-search/src/test/java/com/yahoo/search/result/test/DefaultErrorHitTestCase.java
deleted file mode 100644
index 14e127ec72c..00000000000
--- a/container-search/src/test/java/com/yahoo/search/result/test/DefaultErrorHitTestCase.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.search.result.test;
-
-import com.yahoo.prelude.templates.SearchRendererAdaptor;
-import com.yahoo.search.result.DefaultErrorHit;
-import com.yahoo.search.result.ErrorMessage;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.io.StringWriter;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author bratseth
- */
-public class DefaultErrorHitTestCase {
-
- @Test
- public void testErrorHitRenderingWithException() throws IOException {
- NullPointerException cause=null;
- try {
- Object a=null;
- a.toString();
- }
- catch (NullPointerException e) {
- cause=e;
- }
- StringWriter w=new StringWriter();
- SearchRendererAdaptor.simpleRenderDefaultErrorHit(w, new DefaultErrorHit("test", new ErrorMessage(79, "Myerror", "Mydetail", cause)));
- String sep = System.getProperty("line.separator");
- assertEquals(
- "<errordetails>\n" +
- " <error source=\"test\" error=\"Myerror\" code=\"79\">Mydetail\n" +
- " <cause>\n" +
- "java.lang.NullPointerException" + sep +
- "\tat "
- ,w.toString().substring(0, 119+sep.length()));
- }
-
-}
diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
index 931ee99fdaa..2b0398a8e45 100644
--- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
@@ -13,6 +13,8 @@ import com.yahoo.language.simple.SimpleDetector;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.IndexModel;
+import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.CompositeItem;
import com.yahoo.prelude.query.Highlight;
@@ -40,6 +42,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -769,14 +772,15 @@ public class QueryTestCase {
private void assertDetectionText(String expectedDetectionText, String queryString, String ... indexSpecs) {
Query q = new Query(httpEncode("/?query=" + queryString));
- IndexFacts indexFacts = new IndexFacts();
+ SearchDefinition sd = new SearchDefinition("testSearchDefinition");
for (String indexSpec : indexSpecs) {
String[] specParts = indexSpec.split(":");
Index tokenIndex = new Index(specParts[1]);
if (specParts[0].equals("text"))
tokenIndex.setPlainTokens(true);
- indexFacts.addIndex("testSearchDefinition", tokenIndex);
+ sd.addIndex(tokenIndex);
}
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd)));
MockLinguistics mockLinguistics = new MockLinguistics();
q.getModel().setExecution(new Execution(Execution.Context.createContextStub(null, indexFacts, mockLinguistics)));
q.getModel().getQueryTree(); // cause parsing