summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/IndexFacts.java98
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java62
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/SchemaResolver.java58
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java14
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/NonPhrasingSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/RecallSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/StemmingSearcher.java62
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java8
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java22
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java23
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/semantics/SemanticSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/Query.java70
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/rpc/CompressService.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java12
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java12
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java31
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/GroupingQueryParser.java15
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/UniqueGroupingSearcher.java39
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/result/FlatteningSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/intent/model/IntentModel.java13
-rw-r--r--container-search/src/main/java/com/yahoo/search/pagetemplates/PageTemplateSearcher.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/Model.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/Ranking.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/DefaultProperties.java6
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/SubProperties.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/rewrite/RewriterConstants.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/BooleanSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/SortingDegrader.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java12
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/ranking/GlobalPhaseRanker.java31
-rw-r--r--container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchers/CacheControlSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchers/ConnectionControlSearcher.java2
-rwxr-xr-xcontainer-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java10
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/FieldFiller.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/FieldFilter.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/MinimalQueryInserter.java6
-rw-r--r--container-search/src/main/java/com/yahoo/vespa/streamingvisitors/MetricsSearcher.java7
-rw-r--r--container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java14
54 files changed, 385 insertions, 356 deletions
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 92ce6abb319..88a37ea5a02 100644
--- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
+++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
@@ -6,11 +6,11 @@ import com.yahoo.search.Query;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeSet;
import static com.yahoo.text.Lowercase.toLowerCase;
@@ -32,16 +32,6 @@ public class IndexFacts {
private Map<String, List<String>> clusterByDocument;
- private static class DocumentTypeListOffset {
- public final int offset;
- public final SearchDefinition searchDefinition;
-
- public DocumentTypeListOffset(int offset, SearchDefinition searchDefinition) {
- this.offset = offset;
- this.searchDefinition = searchDefinition;
- }
- }
-
/** A Map of all known search definitions indexed by name */
private Map<String, SearchDefinition> searchDefinitions = new LinkedHashMap<>();
@@ -110,34 +100,32 @@ public class IndexFacts {
private boolean isIndexFromDocumentTypes(String indexName, List<String> documentTypes) {
if ( ! isInitialized()) return true;
- if (documentTypes.isEmpty()) {
- return unionSearchDefinition.getIndex(indexName) != null;
- }
+ if (documentTypes.isEmpty()) return unionSearchDefinition.getIndex(indexName) != null;
- DocumentTypeListOffset sd = chooseSearchDefinition(documentTypes, 0);
- while (sd != null) {
- Index index = sd.searchDefinition.getIndex(indexName);
- if (index != null) {
- return true;
+ for (String docName : documentTypes) {
+ SearchDefinition sd = searchDefinitions.get(docName);
+ if (sd != null) {
+ Index index = sd.getIndex(indexName);
+ if (index != null) return true;
}
- sd = chooseSearchDefinition(documentTypes, sd.offset);
}
-
return false;
}
private String getCanonicNameFromDocumentTypes(String indexName, List<String> documentTypes) {
if (!isInitialized()) return indexName;
+ String lowerCased = toLowerCase(indexName);
if (documentTypes.isEmpty()) {
- Index index = unionSearchDefinition.getIndexByLowerCase(toLowerCase(indexName));
+ Index index = unionSearchDefinition.getIndexByLowerCase(lowerCased);
return index == null ? indexName : index.getName();
}
- DocumentTypeListOffset sd = chooseSearchDefinition(documentTypes, 0);
- while (sd != null) {
- Index index = sd.searchDefinition.getIndexByLowerCase(toLowerCase(indexName));
- if (index != null) return index.getName();
- sd = chooseSearchDefinition(documentTypes, sd.offset);
+ for (String docName : documentTypes) {
+ SearchDefinition sd = searchDefinitions.get(docName);
+ if (sd != null) {
+ Index index = sd.getIndexByLowerCase(lowerCased);
+ if (index != null) return index.getName();
+ }
}
return indexName;
}
@@ -158,13 +146,12 @@ public class IndexFacts {
return index;
}
- DocumentTypeListOffset sd = chooseSearchDefinition(documentTypes, 0);
-
- while (sd != null) {
- Index index = sd.searchDefinition.getIndex(canonicName);
-
- if (index != null) return index;
- sd = chooseSearchDefinition(documentTypes, sd.offset);
+ for (String docName : documentTypes) {
+ SearchDefinition sd = searchDefinitions.get(docName);
+ if (sd != null) {
+ Index index = sd.getIndex(canonicName);
+ if (index != null) return index;
+ }
}
return Index.nullIndex;
}
@@ -187,7 +174,7 @@ public class IndexFacts {
* Given a search list which is a mixture of document types and cluster
* names, and a restrict list which is a list of document types, return a
* set of all valid document types for this combination. Most use-cases for
- * fetching index settings will involve calling this method with the the
+ * fetching index settings will involve calling this method with the
* incoming query's {@link com.yahoo.search.query.Model#getSources()} and
* {@link com.yahoo.search.query.Model#getRestrict()} as input parameters
* before calling any other method of this class.
@@ -196,20 +183,20 @@ public class IndexFacts {
* @param restrict the restrict list for a query
* @return a (possibly empty) set of valid document types
*/
- private Set<String> resolveDocumentTypes(Collection<String> sources, Collection<String> restrict,
+ private Set<String> resolveDocumentTypes(Collection<String> sources, Set<String> restrict,
Set<String> candidateDocumentTypes) {
sources = emptyCollectionIfNull(sources);
- restrict = emptyCollectionIfNull(restrict);
+ restrict = emptySetIfNull(restrict);
if (sources.isEmpty()) {
if ( ! restrict.isEmpty()) {
- return new TreeSet<>(restrict);
+ return Set.copyOf(restrict);
} else {
return candidateDocumentTypes;
}
}
- Set<String> toSearch = new TreeSet<>();
+ Set<String> toSearch = new HashSet<>();
for (String source : sources) { // source: a document type or a cluster containing them
List<String> clusterDocTypes = clusters.get(source);
if (clusterDocTypes == null) { // source was a document type
@@ -235,21 +222,8 @@ public class IndexFacts {
private Collection<String> emptyCollectionIfNull(Collection<String> collection) {
return collection == null ? List.of() : collection;
}
-
- /**
- * Chooses the correct search definition, default if in doubt.
- *
- * @return the search definition to use
- */
- private DocumentTypeListOffset chooseSearchDefinition(List<String> documentTypes, int index) {
- while (index < documentTypes.size()) {
- String docName = documentTypes.get(index++);
- SearchDefinition sd = searchDefinitions.get(docName);
- if (sd != null) {
- return new DocumentTypeListOffset(index, sd);
- }
- }
- return null;
+ private Set<String> emptySetIfNull(Set<String> collection) {
+ return collection == null ? Set.of() : collection;
}
/**
@@ -279,10 +253,6 @@ public class IndexFacts {
return frozen;
}
- private void ensureNotFrozen() {
- if (frozen) throw new IllegalStateException("Tried to modify frozen IndexFacts instance.");
- }
-
public String getDefaultPosition(String sdName) {
SearchDefinition sd;
if (sdName == null) {
@@ -300,12 +270,16 @@ public class IndexFacts {
return new Session(query);
}
- public Session newSession(Collection<String> sources, Collection<String> restrict) {
+ public Session newSession() {
+ return new Session(Set.of(), Set.of());
+ }
+
+ public Session newSession(Collection<String> sources, Set<String> restrict) {
return new Session(sources, restrict);
}
public Session newSession(Collection<String> sources,
- Collection<String> restrict,
+ Set<String> restrict,
Set<String> candidateDocumentTypes) {
return new Session(sources, restrict, candidateDocumentTypes);
}
@@ -323,12 +297,12 @@ public class IndexFacts {
documentTypes = List.copyOf(resolveDocumentTypes(query));
}
- private Session(Collection<String> sources, Collection<String> restrict) {
+ private Session(Collection<String> sources, Set<String> restrict) {
// Assumption: Search definition name equals document name.
documentTypes = List.copyOf(resolveDocumentTypes(sources, restrict, searchDefinitions.keySet()));
}
- private Session(Collection<String> sources, Collection<String> restrict, Set<String> candidateDocumentTypes) {
+ private Session(Collection<String> sources, Set<String> restrict, Set<String> candidateDocumentTypes) {
documentTypes = List.copyOf(resolveDocumentTypes(sources, restrict, candidateDocumentTypes));
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
index 08d8d54bc53..f0e3e3f3e44 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.cluster;
-import com.yahoo.component.annotation.Inject;
import com.yahoo.component.ComponentId;
+import com.yahoo.component.annotation.Inject;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.component.provider.ComponentRegistry;
import com.yahoo.container.QrSearchersConfig;
@@ -28,10 +28,6 @@ import com.yahoo.vespa.streamingvisitors.VdsStreamingSearcher;
import com.yahoo.yolean.Exceptions;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@@ -57,16 +53,14 @@ public class ClusterSearcher extends Searcher {
private final String searchClusterName;
- // The set of document types contained in this search cluster
- private final Set<String> schemas;
+ private final SchemaResolver schemaResolver;
private final long maxQueryTimeout; // in milliseconds
private final long maxQueryCacheTimeout; // in milliseconds
private final VespaBackEndSearcher server;
private final Executor executor;
- private final GlobalPhaseRanker globalPhaseHelper;
- private final boolean enableGlobalPhase;
+ private final GlobalPhaseRanker globalPhaseRanker;
@Inject
public ClusterSearcher(ComponentId id,
@@ -76,16 +70,16 @@ public class ClusterSearcher extends Searcher {
DocumentdbInfoConfig documentDbConfig,
SchemaInfo schemaInfo,
ComponentRegistry<Dispatcher> dispatchers,
- GlobalPhaseRanker globalPhaseHelper,
+ GlobalPhaseRanker globalPhaseRanker,
VipStatus vipStatus,
VespaDocumentAccess access) {
super(id);
this.executor = executor;
- this.globalPhaseHelper = globalPhaseHelper;
int searchClusterIndex = clusterConfig.clusterId();
searchClusterName = clusterConfig.clusterName();
QrSearchersConfig.Searchcluster searchClusterConfig = getSearchClusterConfigFromClusterName(qrsConfig, searchClusterName);
- schemas = new LinkedHashSet<>();
+ this.globalPhaseRanker = searchClusterConfig.globalphase() ? globalPhaseRanker : null;
+ this.schemaResolver = new SchemaResolver(documentDbConfig);
maxQueryTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryTimeout(), DEFAULT_MAX_QUERY_TIMEOUT);
maxQueryCacheTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryCacheTimeout(), DEFAULT_MAX_QUERY_CACHE_TIMEOUT);
@@ -94,9 +88,6 @@ public class ClusterSearcher extends Searcher {
.com().yahoo().prelude().fastsearch().FastSearcher().docsum()
.defaultclass());
- for (DocumentdbInfoConfig.Documentdb docDb : documentDbConfig.documentdb())
- schemas.add(docDb.name());
-
String uniqueServerId = UUID.randomUUID().toString();
if (searchClusterConfig.indexingmode() == STREAMING) {
server = vdsCluster(uniqueServerId, searchClusterIndex,
@@ -106,7 +97,6 @@ public class ClusterSearcher extends Searcher {
server = searchDispatch(searchClusterIndex, searchClusterName, uniqueServerId,
docSumParams, documentDbConfig, schemaInfo, dispatchers);
}
- enableGlobalPhase = searchClusterConfig.globalphase();
}
private static QrSearchersConfig.Searchcluster getSearchClusterConfigFromClusterName(QrSearchersConfig config, String name) {
@@ -159,14 +149,13 @@ public class ClusterSearcher extends Searcher {
/** Do not use, for internal testing purposes only. **/
ClusterSearcher(Set<String> schemas, VespaBackEndSearcher searcher, Executor executor) {
- this.schemas = schemas;
+ this.schemaResolver = new SchemaResolver(schemas);
searchClusterName = "testScenario";
maxQueryTimeout = DEFAULT_MAX_QUERY_TIMEOUT;
maxQueryCacheTimeout = DEFAULT_MAX_QUERY_CACHE_TIMEOUT;
server = searcher;
this.executor = executor;
- this.globalPhaseHelper = null;
- this.enableGlobalPhase = false;
+ this.globalPhaseRanker = null;
}
/** Do not use, for internal testing purposes only. **/
@@ -232,8 +221,9 @@ public class ClusterSearcher extends Searcher {
}
private Result doSearch(Searcher searcher, Query query, Execution execution) {
+ var schemas = schemaResolver.resolve(query, execution);
if (schemas.size() > 1) {
- return searchMultipleDocumentTypes(searcher, query, execution);
+ return searchMultipleDocumentTypes(searcher, query, execution, schemas);
} else {
String docType = schemas.iterator().next();
query.getModel().setRestrict(docType);
@@ -247,10 +237,13 @@ public class ClusterSearcher extends Searcher {
throw new IllegalStateException("perSchemaSearch must always be called with 1 schema, got: " + restrict.size());
}
String schema = restrict.iterator().next();
- Result result = searcher.search(query, execution);
- if (globalPhaseHelper != null && enableGlobalPhase) {
- globalPhaseHelper.process(query, result, schema);
+ boolean useGlobalPhase = globalPhaseRanker != null;
+ if (useGlobalPhase) {
+ var error = globalPhaseRanker.validateNoSorting(query, schema).orElse(null);
+ if (error != null) return new Result(query, error);
}
+ Result result = searcher.search(query, execution);
+ if (useGlobalPhase) globalPhaseRanker.rerankHits(query, result, schema);
return result;
}
@@ -266,8 +259,7 @@ public class ClusterSearcher extends Searcher {
}
}
- private Result searchMultipleDocumentTypes(Searcher searcher, Query query, Execution execution) {
- Set<String> schemas = resolveSchemas(query, execution.context().getIndexFacts());
+ private Result searchMultipleDocumentTypes(Searcher searcher, Query query, Execution execution, Set<String> schemas) {
List<Query> queries = createQueries(query, schemas);
if (queries.size() == 1) {
return perSchemaSearch(searcher, queries.get(0), execution);
@@ -301,25 +293,7 @@ public class ClusterSearcher extends Searcher {
}
Set<String> resolveSchemas(Query query, IndexFacts indexFacts) {
- Set<String> restrict = query.getModel().getRestrict();
- if (restrict == null || restrict.isEmpty()) {
- Set<String> sources = query.getModel().getSources();
- return (sources == null || sources.isEmpty())
- ? schemas
- : new HashSet<>(indexFacts.newSession(sources, Collections.emptyList(), schemas).documentTypes());
- } else {
- return filterValidDocumentTypes(restrict);
- }
- }
-
- private Set<String> filterValidDocumentTypes(Collection<String> restrict) {
- Set<String> retval = new LinkedHashSet<>();
- for (String docType : restrict) {
- if (docType != null && schemas.contains(docType)) {
- retval.add(docType);
- }
- }
- return retval;
+ return schemaResolver.resolve(query, indexFacts);
}
private List<Query> createQueries(Query query, Set<String> docTypes) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/SchemaResolver.java b/container-search/src/main/java/com/yahoo/prelude/cluster/SchemaResolver.java
new file mode 100644
index 00000000000..3a2125d1d38
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/SchemaResolver.java
@@ -0,0 +1,58 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+package com.yahoo.prelude.cluster;
+
+import com.yahoo.prelude.IndexFacts;
+import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
+import com.yahoo.search.Query;
+import com.yahoo.search.searchchain.Execution;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * Resolves schemas from query and execution context
+ *
+ * @author bjorncs
+ */
+class SchemaResolver {
+
+ private final Set<String> schemas;
+
+ SchemaResolver(DocumentdbInfoConfig cfg) {
+ this(cfg.documentdb().stream().map(DocumentdbInfoConfig.Documentdb::name).toList());
+ }
+
+ SchemaResolver(Collection<String> schemas) {
+ this.schemas = new LinkedHashSet<>(schemas);
+ }
+
+ Set<String> resolve(Query query, Execution execution) {
+ return resolve(query, execution.context().getIndexFacts());
+ }
+
+ Set<String> resolve(Query query, IndexFacts indexFacts) {
+ if (schemas.size() == 1) return Set.of(schemas.iterator().next());
+ var restrict = query.getModel().getRestrict();
+ if (restrict == null || restrict.isEmpty()) {
+ Set<String> sources = query.getModel().getSources();
+ return (sources == null || sources.isEmpty())
+ ? schemas
+ : new LinkedHashSet<>(indexFacts.newSession(sources, Set.of(), schemas).documentTypes());
+ } else {
+ return filterValidDocumentTypes(restrict);
+ }
+ }
+
+ private Set<String> filterValidDocumentTypes(Collection<String> restrict) {
+ Set<String> retval = new LinkedHashSet<>();
+ for (String docType : restrict) {
+ if (docType != null && schemas.contains(docType)) {
+ retval.add(docType);
+ }
+ }
+ return retval;
+ }
+
+}
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java
index e3b2278475b..2bd408220cd 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java
@@ -6,7 +6,6 @@ import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.query.Item;
import com.yahoo.search.query.parser.Parser;
-import java.util.Collections;
import java.util.Set;
/**
@@ -23,7 +22,7 @@ public interface CustomParser extends Parser {
Set<String> toSearch, IndexFacts indexFacts, String defaultIndexName) {
if (indexFacts == null)
indexFacts = new IndexFacts();
- return parse(queryToParse, filterToParse, parsingLanguage, indexFacts.newSession(toSearch, Collections.emptySet()), defaultIndexName);
+ return parse(queryToParse, filterToParse, parsingLanguage, indexFacts.newSession(toSearch, Set.of()), defaultIndexName);
}
Item parse(String queryToParse, String filterToParse, Language parsingLanguage,
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java
index c1d415b8e27..9952ec64d13 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java
@@ -8,7 +8,6 @@ import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.query.Substring;
-import java.util.Collections;
import java.util.List;
import static com.yahoo.prelude.query.parser.Token.Kind.*;
@@ -63,7 +62,7 @@ public final class Tokenizer {
* @return a read-only list of tokens. This list can only be used by this thread
*/
public List<Token> tokenize(String string) {
- return tokenize(string, new IndexFacts().newSession(Collections.emptySet(), Collections.emptySet()));
+ return tokenize(string, new IndexFacts().newSession());
}
/**
@@ -171,13 +170,10 @@ public final class Tokenizer {
// this is a heuristic to check whether we probably have reached the end of an URL element
for (int i = tokens.size() - 1; i >= 0; --i) {
switch (tokens.get(i).kind) {
- case COLON:
- if (i == indexLastExplicitlyChangedAt) return false;
- break;
- case SPACE:
- return true;
- default:
- // do nothing
+ case COLON -> { if (i == indexLastExplicitlyChangedAt) return false; }
+ case SPACE -> { return true; }
+ default -> { }
+ // do nothing
}
}
// really not sure whether we should choose false instead, on cause of the guard at
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/NonPhrasingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/NonPhrasingSearcher.java
index 6bae5175d84..1eb7eb8abe7 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/NonPhrasingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/NonPhrasingSearcher.java
@@ -22,7 +22,7 @@ import java.util.List;
@Before("transformedQuery")
public class NonPhrasingSearcher extends Searcher {
- private static final CompoundName suggestonly=new CompoundName("suggestonly");
+ private static final CompoundName suggestonly = CompoundName.from("suggestonly");
private PhraseMatcher phraseMatcher;
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java
index b67ddade7ee..4da61f5eeca 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java
@@ -29,7 +29,7 @@ import java.util.List;
@Provides(PhrasingSearcher.PHRASE_REPLACEMENT)
public class PhrasingSearcher extends Searcher {
- private static final CompoundName suggestonly = new CompoundName("suggestonly");
+ private static final CompoundName suggestonly = CompoundName.from("suggestonly");
public static final String PHRASE_REPLACEMENT = "PhraseReplacement";
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/RecallSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/RecallSearcher.java
index 2c7d78c0671..9f8facd2b28 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/RecallSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/RecallSearcher.java
@@ -39,7 +39,7 @@ import static com.yahoo.prelude.querytransform.StemmingSearcher.STEMMING;
@Before({STEMMING, ACCENT_REMOVAL})
public class RecallSearcher extends Searcher {
- public static final CompoundName recallName=new CompoundName("recall");
+ public static final CompoundName recallName = CompoundName.from("recall");
@Override
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/StemmingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/StemmingSearcher.java
index 6aa262ca49e..7c4bcb38c41 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/StemmingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/StemmingSearcher.java
@@ -9,11 +9,33 @@ import com.yahoo.language.Language;
import com.yahoo.language.Linguistics;
import com.yahoo.language.process.StemMode;
import com.yahoo.language.process.StemList;
+
+import java.util.ArrayList;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
import java.util.logging.Level;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
-import com.yahoo.prelude.query.*;
+import com.yahoo.prelude.query.AndItem;
+import com.yahoo.prelude.query.AndSegmentItem;
+import com.yahoo.prelude.query.BlockItem;
+import com.yahoo.prelude.query.CompositeItem;
+import com.yahoo.prelude.query.Highlight;
+import com.yahoo.prelude.query.Item;
+import com.yahoo.prelude.query.PhraseItem;
+import com.yahoo.prelude.query.PhraseSegmentItem;
+import com.yahoo.prelude.query.PrefixItem;
+import com.yahoo.prelude.query.SegmentingRule;
+import com.yahoo.prelude.query.Substring;
+import com.yahoo.prelude.query.TaggableItem;
+import com.yahoo.prelude.query.TermItem;
+import com.yahoo.prelude.query.WordAlternativesItem;
import com.yahoo.prelude.query.WordAlternativesItem.Alternative;
+import com.yahoo.prelude.query.WordItem;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
@@ -21,7 +43,6 @@ import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.PhaseNames;
-import java.util.*;
import static com.yahoo.prelude.querytransform.CJKSearcher.TERM_ORDER_RELAXATION;
@@ -46,7 +67,7 @@ public class StemmingSearcher extends Searcher {
}
public static final String STEMMING = "Stemming";
- public static final CompoundName DISABLE = new CompoundName("nostemming");
+ public static final CompoundName DISABLE = CompoundName.from("nostemming");
private final Linguistics linguistics;
public StemmingSearcher(Linguistics linguistics) {
@@ -107,15 +128,13 @@ public class StemmingSearcher extends Searcher {
}
private Map<Item, TaggableItem> populateReverseConnectivityMap(Item root, Map<Item, TaggableItem> reverseConnectivity) {
- if (root instanceof TaggableItem) {
- TaggableItem asTaggable = (TaggableItem) root;
+ if (root instanceof TaggableItem asTaggable) {
Item connectsTo = asTaggable.getConnectedItem();
if (connectsTo != null) {
reverseConnectivity.put(connectsTo, asTaggable);
}
}
- if (root instanceof CompositeItem && !(root instanceof BlockItem)) {
- CompositeItem c = (CompositeItem) root;
+ if (root instanceof CompositeItem c && !(root instanceof BlockItem)) {
for (Iterator<Item> i = c.getItemIterator(); i.hasNext();) {
Item item = i.next();
populateReverseConnectivityMap(item, reverseConnectivity);
@@ -134,8 +153,7 @@ public class StemmingSearcher extends Searcher {
}
if (item instanceof BlockItem) {
item = checkBlock((BlockItem) item, context);
- } else if (item instanceof CompositeItem) {
- CompositeItem comp = (CompositeItem) item;
+ } else if (item instanceof CompositeItem comp) {
ListIterator<Item> i = comp.getItemIterator();
while (i.hasNext()) {
@@ -220,8 +238,7 @@ public class StemmingSearcher extends Searcher {
copyAttributes(blockAsItem, composite);
composite.lock();
- if (composite instanceof PhraseSegmentItem) {
- PhraseSegmentItem replacement = (PhraseSegmentItem) composite;
+ if (composite instanceof PhraseSegmentItem replacement) {
setSignificance(replacement, current);
phraseSegmentConnectivity(current, context.reverseConnectivity, replacement);
}
@@ -258,10 +275,9 @@ public class StemmingSearcher extends Searcher {
}
private Connectivity getConnectivity(BlockItem current) {
- if (!(current instanceof TaggableItem)) {
+ if (!(current instanceof TaggableItem t)) {
return null;
}
- TaggableItem t = (TaggableItem) current;
if (t.getConnectedItem() == null) {
return null;
}
@@ -294,7 +310,7 @@ public class StemmingSearcher extends Searcher {
Substring substring,
boolean insidePhrase) {
String indexName = current.getIndexName();
- if (insidePhrase == false && ((index.getLiteralBoost() || index.getStemMode() == StemMode.ALL))) {
+ if (!insidePhrase && ((index.getLiteralBoost() || index.getStemMode() == StemMode.ALL))) {
List<Alternative> terms = new ArrayList<>(segment.size() + 1);
terms.add(new Alternative(current.stringValue(), 1.0d));
for (String term : segment) {
@@ -305,8 +321,7 @@ public class StemmingSearcher extends Searcher {
return alternatives;
}
}
- WordItem first = singleStemSegment((Item) current, segment.get(0), indexName, substring);
- return first;
+ return singleStemSegment((Item) current, segment.get(0), indexName, substring);
}
private void setMetaData(BlockItem current, Map<Item, TaggableItem> reverseConnectivity, TaggableItem replacement) {
@@ -353,14 +368,13 @@ public class StemmingSearcher extends Searcher {
if (current.getSegmentingRule() == SegmentingRule.LANGUAGE_DEFAULT)
return chooseComposite(current, parent, indexName);
- switch (current.getSegmentingRule()) { // TODO: Why for CJK only? The segmentingRule says nothing about being for CJK only
- case PHRASE: return createPhraseSegment(current, indexName);
- case BOOLEAN_AND: return createAndSegment(current);
- default:
- throw new IllegalArgumentException("Unknown segmenting rule: " + current.getSegmentingRule() +
- ". This is a bug in Vespa, as the implementation has gotten out of sync." +
- " Please create an issue.");
- }
+ return switch (current.getSegmentingRule()) { // TODO: Why for CJK only? The segmentingRule says nothing about being for CJK only
+ case PHRASE -> createPhraseSegment(current, indexName);
+ case BOOLEAN_AND -> createAndSegment(current);
+ default -> throw new IllegalArgumentException("Unknown segmenting rule: " + current.getSegmentingRule() +
+ ". This is a bug in Vespa, as the implementation has gotten out of sync." +
+ " Please create an issue.");
+ };
}
private AndSegmentItem createAndSegment(BlockItem current) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java
index ead6ad53715..9927880c476 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java
@@ -25,10 +25,10 @@ import java.util.Map;
@Before(PhaseNames.TRANSFORMED_QUERY)
public class FieldCollapsingSearcher extends Searcher {
- private static final CompoundName collapse = new CompoundName("collapse");
- private static final CompoundName collapsefield = new CompoundName("collapsefield");
- private static final CompoundName collapsesize = new CompoundName("collapsesize");
- private static final CompoundName collapseSummaryName = new CompoundName("collapse.summary");
+ private static final CompoundName collapse = CompoundName.from("collapse");
+ private static final CompoundName collapsefield = CompoundName.from("collapsefield");
+ private static final CompoundName collapsesize = CompoundName.from("collapsesize");
+ private static final CompoundName collapseSummaryName = CompoundName.from("collapse.summary");
/** Maximum number of queries to send next searcher */
private static final int maxQueries = 4;
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java
index 10b2cf0fdc7..7750bd17108 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java
@@ -25,7 +25,7 @@ public class JSONDebugSearcher extends Searcher {
public static final String STRUCT_FIELD = "Structured data field (as json): ";
public static final String FEATURE_FIELD = "Feature data field (as json): ";
- private static CompoundName PROPERTYNAME = new CompoundName("dumpjson");
+ private static final CompoundName PROPERTYNAME = CompoundName.from("dumpjson");
@Override
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java
index 3c61a361cbb..dd2c4a1da7f 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java
@@ -10,7 +10,12 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Groups hits according to document type.
@@ -21,9 +26,9 @@ import java.util.*;
public class MultipleResultsSearcher extends Searcher {
private final static String propertyPrefix = "multipleresultsets.";
- private static final CompoundName additionalHitsFactorName=new CompoundName(propertyPrefix + "additionalHitsFactor");
- private static final CompoundName maxTimesRetrieveHeterogeneousHitsName=new CompoundName(propertyPrefix + "maxTimesRetrieveHeterogeneousHits");
- private static final CompoundName numHits=new CompoundName(propertyPrefix + "numHits");
+ private static final CompoundName additionalHitsFactorName = CompoundName.from(propertyPrefix + "additionalHitsFactor");
+ private static final CompoundName maxTimesRetrieveHeterogeneousHitsName = CompoundName.from(propertyPrefix + "maxTimesRetrieveHeterogeneousHits");
+ private static final CompoundName numHits = CompoundName.from(propertyPrefix + "numHits");
@Override
public Result search(Query query, Execution e) {
@@ -162,9 +167,9 @@ public class MultipleResultsSearcher extends Searcher {
// Assumes that field sddocname is available
private static class PartitionedResult {
- private Map<String, HitGroup> resultSets = new HashMap<>();
+ private final Map<String, HitGroup> resultSets = new HashMap<>();
- private List<Hit> otherHits = new ArrayList<>();
+ private final List<Hit> otherHits = new ArrayList<>();
PartitionedResult(List<DocumentGroup> documentGroups,Result result) throws ParameterException {
for (DocumentGroup group : documentGroups)
@@ -174,9 +179,8 @@ public class MultipleResultsSearcher extends Searcher {
}
void addHits(Result result, boolean addOtherHits) {
- Iterator<Hit> i = result.hits().iterator();
- while (i.hasNext()) {
- add(i.next(), addOtherHits);
+ for (Hit hit : result.hits()) {
+ add(hit, addOtherHits);
}
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java
index 0df21df8842..fd4c9e89f3b 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java
@@ -37,12 +37,11 @@ public class PosSearcher extends Searcher {
public static final String POSITION_PARSING = "PositionParsing";
- private static final CompoundName posBb = new CompoundName("pos.bb");
- private static final CompoundName posLl = new CompoundName("pos.ll");
- private static final CompoundName posXy = new CompoundName("pos.xy");
- private static final CompoundName posAttributeName = new CompoundName("pos.attribute");
- private static final CompoundName posRadius = new CompoundName("pos.radius");
- private static final CompoundName posUnits = new CompoundName("pos.units");
+ private static final CompoundName posBb = CompoundName.from("pos.bb");
+ private static final CompoundName posLl = CompoundName.from("pos.ll");
+ private static final CompoundName posXy = CompoundName.from("pos.xy");
+ private static final CompoundName posAttributeName = CompoundName.from("pos.attribute");
+ private static final CompoundName posRadius = CompoundName.from("pos.radius");
// according to wikipedia:
// Earth's equatorial radius = 6378137 meter - not used
@@ -117,13 +116,13 @@ public class PosSearcher extends Searcher {
if (radius == null) {
radiusdegrees = 50.0 * km2deg;
} else if (radius.endsWith("km")) {
- double radiuskm = Double.valueOf(radius.substring(0, radius.length()-2));
+ double radiuskm = Double.parseDouble(radius.substring(0, radius.length()-2));
radiusdegrees = radiuskm * km2deg;
} else if (radius.endsWith("m")) {
- double radiusm = Double.valueOf(radius.substring(0, radius.length()-1));
+ double radiusm = Double.parseDouble(radius.substring(0, radius.length()-1));
radiusdegrees = radiusm * km2deg / 1000.0;
} else if (radius.endsWith("mi")) {
- double radiusmiles = Double.valueOf(radius.substring(0, radius.length()-2));
+ double radiusmiles = Double.parseDouble(radius.substring(0, radius.length()-2));
radiusdegrees = radiusmiles * mi2deg;
} else {
radiusdegrees = Integer.parseInt(radius) * 0.000001;
@@ -151,15 +150,15 @@ public class PosSearcher extends Searcher {
double radiusdegrees = radiuskm * km2deg;
radiusUnits = (int)(radiusdegrees * 1000000);
} else if (radius.endsWith("km")) {
- double radiuskm = Double.valueOf(radius.substring(0, radius.length()-2));
+ double radiuskm = Double.parseDouble(radius.substring(0, radius.length()-2));
double radiusdegrees = radiuskm * km2deg;
radiusUnits = (int)(radiusdegrees * 1000000);
} else if (radius.endsWith("m")) {
- double radiusm = Double.valueOf(radius.substring(0, radius.length()-1));
+ double radiusm = Double.parseDouble(radius.substring(0, radius.length()-1));
double radiusdegrees = radiusm * km2deg / 1000.0;
radiusUnits = (int)(radiusdegrees * 1000000);
} else if (radius.endsWith("mi")) {
- double radiusmiles = Double.valueOf(radius.substring(0, radius.length()-2));
+ double radiusmiles = Double.parseDouble(radius.substring(0, radius.length()-2));
double radiusdegrees = radiusmiles * mi2deg;
radiusUnits = (int)(radiusdegrees * 1000000);
} else {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java
index 5488334c838..701e5d57950 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java
@@ -3,16 +3,16 @@ package com.yahoo.prelude.searcher;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.component.chain.dependencies.Before;
-import com.yahoo.vespa.config.search.AttributesConfig;
-import com.yahoo.search.config.ClusterConfig;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
+import com.yahoo.search.config.ClusterConfig;
import com.yahoo.search.query.Sorting;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.PhaseNames;
+import com.yahoo.vespa.config.search.AttributesConfig;
import java.util.HashMap;
import java.util.List;
diff --git a/container-search/src/main/java/com/yahoo/prelude/semantics/SemanticSearcher.java b/container-search/src/main/java/com/yahoo/prelude/semantics/SemanticSearcher.java
index 42a2b4f4e9b..5b3806485b5 100644
--- a/container-search/src/main/java/com/yahoo/prelude/semantics/SemanticSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/semantics/SemanticSearcher.java
@@ -29,9 +29,9 @@ import static com.yahoo.prelude.querytransform.StemmingSearcher.STEMMING;
@Before({PhaseNames.TRANSFORMED_QUERY, STEMMING})
public class SemanticSearcher extends Searcher {
- private static final CompoundName rulesRulebase = new CompoundName("rules.rulebase");
- private static final CompoundName rulesOff = new CompoundName("rules.off");
- private static final CompoundName tracelevelRules = new CompoundName("tracelevel.rules");
+ private static final CompoundName rulesRulebase = CompoundName.from("rules.rulebase");
+ private static final CompoundName rulesOff = CompoundName.from("rules.off");
+ private static final CompoundName tracelevelRules = CompoundName.from("tracelevel.rules");
/** The default rule base of this */
private RuleBase defaultRuleBase;
diff --git a/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java b/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
index c13bdff1f50..de24196327e 100644
--- a/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
@@ -56,7 +56,7 @@ import static com.yahoo.container.protect.Error.UNSPECIFIED;
@Before(PhaseNames.RAW_QUERY)
public class StatisticsSearcher extends Searcher {
- private static final CompoundName IGNORE_QUERY = new CompoundName("metrics.ignore");
+ private static final CompoundName IGNORE_QUERY = CompoundName.from("metrics.ignore");
private static final String MAX_QUERY_LATENCY_METRIC = ContainerMetrics.MAX_QUERY_LATENCY.baseName();
private static final String EMPTY_RESULTS_METRIC = ContainerMetrics.EMPTY_RESULTS.baseName();
private static final String HITS_PER_QUERY_METRIC = ContainerMetrics.HITS_PER_QUERY.baseName();
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 cff43e07d70..73ed89687fe 100644
--- a/container-search/src/main/java/com/yahoo/search/Query.java
+++ b/container-search/src/main/java/com/yahoo/search/Query.java
@@ -48,7 +48,6 @@ import com.yahoo.yolean.Exceptions;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -180,23 +179,23 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
//---------------- Static property handling ------------------------------------
- public static final CompoundName OFFSET = new CompoundName("offset");
- public static final CompoundName HITS = new CompoundName("hits");
+ public static final CompoundName OFFSET = CompoundName.from("offset");
+ public static final CompoundName HITS = CompoundName.from("hits");
- public static final CompoundName QUERY_PROFILE = new CompoundName("queryProfile");
- public static final CompoundName SEARCH_CHAIN = new CompoundName("searchChain");
+ public static final CompoundName QUERY_PROFILE = CompoundName.from("queryProfile");
+ public static final CompoundName SEARCH_CHAIN = CompoundName.from("searchChain");
- public static final CompoundName NO_CACHE = new CompoundName("noCache");
- public static final CompoundName GROUPING_SESSION_CACHE = new CompoundName("groupingSessionCache");
- public static final CompoundName TIMEOUT = new CompoundName("timeout");
+ public static final CompoundName NO_CACHE = CompoundName.from("noCache");
+ public static final CompoundName GROUPING_SESSION_CACHE = CompoundName.from("groupingSessionCache");
+ public static final CompoundName TIMEOUT = CompoundName.from("timeout");
/** @deprecated use Trace.LEVEL */
@Deprecated // TODO: Remove on Vespa 9
- public static final CompoundName TRACE_LEVEL = new CompoundName("traceLevel");
+ public static final CompoundName TRACE_LEVEL = CompoundName.from("traceLevel");
/** @deprecated use Trace.EXPLAIN_LEVEL */
@Deprecated // TODO: Remove on Vespa 9
- public static final CompoundName EXPLAIN_LEVEL = new CompoundName("explainLevel");
+ public static final CompoundName EXPLAIN_LEVEL = CompoundName.from("explainLevel");
private static final QueryProfileType argumentType;
static {
@@ -228,17 +227,17 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
private static final Map<String, CompoundName> propertyAliases;
static {
Map<String, CompoundName> propertyAliasesBuilder = new HashMap<>();
- addAliases(Query.getArgumentType(), CompoundName.empty, propertyAliasesBuilder);
+ addAliases(Query.getArgumentType(), "", propertyAliasesBuilder);
propertyAliases = ImmutableMap.copyOf(propertyAliasesBuilder);
}
- private static void addAliases(QueryProfileType arguments, CompoundName prefix, Map<String, CompoundName> aliases) {
+ private static void addAliases(QueryProfileType arguments, String prefix, Map<String, CompoundName> aliases) {
for (FieldDescription field : arguments.fields().values()) {
for (String alias : field.getAliases())
- aliases.put(alias, prefix.append(field.getName()));
+ aliases.put(alias, CompoundName.from(append(prefix, field.getName())));
if (field.getType() instanceof QueryProfileFieldType) {
var type = ((QueryProfileFieldType) field.getType()).getQueryProfileType();
if (type != null)
- addAliases(type, prefix.append(type.getComponentIdAsCompoundName()), aliases);
+ addAliases(type, append(prefix, type.getComponentIdAsCompoundName().toString()), aliases);
}
}
}
@@ -261,18 +260,18 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
/** Returns an unmodifiable list of all the native properties under a Query */
public static final List<CompoundName> nativeProperties =
- List.copyOf(namesUnder(CompoundName.empty, Query.getArgumentType()));
+ List.copyOf(namesUnder("", Query.getArgumentType()));
- private static List<CompoundName> namesUnder(CompoundName prefix, QueryProfileType type) {
- if (type == null) return Collections.emptyList(); // Names not known statically
+ private static List<CompoundName> namesUnder(String prefix, QueryProfileType type) {
+ if (type == null) return List.of(); // Names not known statically
List<CompoundName> names = new ArrayList<>();
for (Map.Entry<String, FieldDescription> field : type.fields().entrySet()) {
+ String name = append(prefix, field.getKey());
if (field.getValue().getType() instanceof QueryProfileFieldType) {
- names.addAll(namesUnder(prefix.append(field.getKey()),
- ((QueryProfileFieldType) field.getValue().getType()).getQueryProfileType()));
+ names.addAll(namesUnder(name, ((QueryProfileFieldType) field.getValue().getType()).getQueryProfileType()));
}
else {
- names.add(prefix.append(field.getKey()));
+ names.add(CompoundName.from(name));
}
}
return names;
@@ -426,28 +425,36 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
* dependent objects for the appropriate subset of the given property values
*/
private void setFieldsFrom(Properties properties, Map<String, String> context) {
- setFrom(CompoundName.empty, properties, Query.getArgumentType(), context);
+ setFrom("", properties, Query.getArgumentType(), context);
+ }
+
+ private static String append(String a, String b) {
+ if (a.isEmpty()) return b;
+ if (b.isEmpty()) return a;
+ return a + "." + b;
}
/**
* For each field in the given query profile type, take the corresponding value from originalProperties
* (if any) set it to properties(), recursively.
*/
- private void setFrom(CompoundName prefix, Properties originalProperties, QueryProfileType arguments, Map<String, String> context) {
- prefix = prefix.append(getPrefix(arguments));
+ private void setFrom(String prefix, Properties originalProperties, QueryProfileType arguments, Map<String, String> context) {
+ prefix = append(prefix, getPrefix(arguments).toString());
for (FieldDescription field : arguments.fields().values()) {
if (field.getType() == FieldType.genericQueryProfileType) { // Generic map
- CompoundName fullName = prefix.append(field.getCompoundName());
- for (Map.Entry<String, Object> entry : originalProperties.listProperties(fullName, context).entrySet()) {
- properties().set(fullName.append(entry.getKey()), entry.getValue(), context);
+ String fullName = append(prefix, field.getCompoundName().toString());
+ for (Map.Entry<String, Object> entry : originalProperties.listProperties(CompoundName.from(fullName), context).entrySet()) {
+ properties().set(CompoundName.from(append(fullName, entry.getKey())), entry.getValue(), context);
}
}
else if (field.getType() instanceof QueryProfileFieldType) { // Nested arguments
setFrom(prefix, originalProperties, ((QueryProfileFieldType)field.getType()).getQueryProfileType(), context);
}
else {
- CompoundName fullName = prefix.append(field.getCompoundName());
+ CompoundName fullName = prefix.isEmpty()
+ ? field.getCompoundName()
+ : CompoundName.from(append(prefix, field.getCompoundName().toString()));
Object value = originalProperties.get(fullName, context);
if (value != null) {
properties().set(fullName, value, context);
@@ -458,14 +465,15 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
/** Calls properties.set on all entries in requestMap */
private void setPropertiesFromRequestMap(Map<String, String> requestMap, Properties properties, boolean ignoreSelect) {
- for (var entry : requestMap.entrySet()) {
+ var entrySet = requestMap.entrySet();
+ for (var entry : entrySet) {
if (ignoreSelect && entry.getKey().equals(Select.SELECT)) continue;
if (RankFeatures.isFeatureName(entry.getKey())) continue; // Set these last
- properties.set(entry.getKey(), entry.getValue(), requestMap);
+ properties.set(CompoundName.from(entry.getKey()), entry.getValue(), requestMap);
}
- for (var entry : requestMap.entrySet()) {
+ for (var entry : entrySet) {
if ( ! RankFeatures.isFeatureName(entry.getKey())) continue;
- properties.set(entry.getKey(), entry.getValue(), requestMap);
+ properties.set(CompoundName.from(entry.getKey()), entry.getValue(), requestMap);
}
}
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
index 09db1be4732..4e4b77422c1 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
@@ -52,7 +52,7 @@ public class Dispatcher extends AbstractComponent {
private static final int MAX_GROUP_SELECTION_ATTEMPTS = 3;
/** If set will control computation of how many hits will be fetched from each partition.*/
- public static final CompoundName topKProbability = CompoundName.fromComponents(DISPATCH, TOP_K_PROBABILITY);
+ public static final CompoundName topKProbability = CompoundName.from(DISPATCH + "." + TOP_K_PROBABILITY);
private final DispatchConfig dispatchConfig;
private final RpcResourcePool rpcResourcePool;
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/CompressService.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/CompressService.java
index 9e7fc9b5b29..c10375a3014 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/CompressService.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/CompressService.java
@@ -13,7 +13,7 @@ import com.yahoo.search.Query;
*/
public class CompressService implements CompressPayload {
/** The compression method which will be used with rpc dispatch. "lz4" (default) and "none" is supported. */
- public final static CompoundName dispatchCompression = new CompoundName("dispatch.compression");
+ public static final CompoundName dispatchCompression = CompoundName.from("dispatch.compression");
private final Compressor compressor = new Compressor(CompressionType.LZ4, 5, 0.95, 256);
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java
index 4466b03a713..154002c4f77 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java
@@ -20,11 +20,20 @@ public class RpcInvokerFactory extends InvokerFactory {
private final RpcConnectionPool rpcResourcePool;
private final CompressPayload compressor;
+ private final RpcProtobufFillInvoker.DecodePolicy decodeType;
+
+ private static RpcProtobufFillInvoker.DecodePolicy convert(DispatchConfig.SummaryDecodePolicy.Enum decoding) {
+ return switch (decoding) {
+ case EAGER -> RpcProtobufFillInvoker.DecodePolicy.EAGER;
+ case ONDEMAND -> RpcProtobufFillInvoker.DecodePolicy.ONDEMAND;
+ };
+ }
public RpcInvokerFactory(RpcConnectionPool rpcResourcePool, SearchGroups cluster, DispatchConfig dispatchConfig) {
super(cluster, dispatchConfig);
this.rpcResourcePool = rpcResourcePool;
this.compressor = new CompressService();
+ decodeType = convert(dispatchConfig.summaryDecodePolicy());
}
@Override
@@ -37,6 +46,7 @@ public class RpcInvokerFactory extends InvokerFactory {
Query query = result.getQuery();
boolean summaryNeedsQuery = searcher.summaryNeedsQuery(query);
- return new RpcProtobufFillInvoker(rpcResourcePool, compressor, searcher.getDocumentDatabase(query), searcher.getServerId(), summaryNeedsQuery);
+ return new RpcProtobufFillInvoker(rpcResourcePool, compressor, searcher.getDocumentDatabase(query),
+ searcher.getServerId(), decodeType, summaryNeedsQuery);
}
}
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java
index 4e538fb54dc..2bdafecfaba 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java
@@ -21,6 +21,7 @@ import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.slime.ArrayTraverser;
import com.yahoo.slime.BinaryFormat;
+import com.yahoo.slime.BinaryView;
import java.util.Iterator;
import java.util.List;
@@ -42,11 +43,14 @@ public class RpcProtobufFillInvoker extends FillInvoker {
private static final Logger log = Logger.getLogger(RpcProtobufFillInvoker.class.getName());
+ enum DecodePolicy {EAGER, ONDEMAND}
+
private final DocumentDatabase documentDb;
private final RpcConnectionPool resourcePool;
private final boolean summaryNeedsQuery;
private final String serverId;
private final CompressPayload compressor;
+ private final DecodePolicy decodePolicy;
private BlockingQueue<Pair<Client.ResponseOrError<ProtobufResponse>, List<FastHit>>> responses;
@@ -56,12 +60,14 @@ public class RpcProtobufFillInvoker extends FillInvoker {
/** The number of responses we should receive (and process) before this is complete */
private int outstandingResponses;
- RpcProtobufFillInvoker(RpcConnectionPool resourcePool, CompressPayload compressor, DocumentDatabase documentDb, String serverId, boolean summaryNeedsQuery) {
+ RpcProtobufFillInvoker(RpcConnectionPool resourcePool, CompressPayload compressor, DocumentDatabase documentDb,
+ String serverId, DecodePolicy decodePolicy, boolean summaryNeedsQuery) {
this.documentDb = documentDb;
this.resourcePool = resourcePool;
this.serverId = serverId;
this.summaryNeedsQuery = summaryNeedsQuery;
this.compressor = compressor;
+ this.decodePolicy = decodePolicy;
}
@Override
@@ -211,7 +217,9 @@ public class RpcProtobufFillInvoker extends FillInvoker {
private int fill(Result result, List<FastHit> hits, String summaryClass, byte[] payload) {
try {
var protobuf = SearchProtocol.DocsumReply.parseFrom(payload);
- var root = BinaryFormat.decode(protobuf.getSlimeSummaries().toByteArray()).get();
+ var root = (decodePolicy == DecodePolicy.ONDEMAND)
+ ? BinaryView.inspect(protobuf.getSlimeSummaries().toByteArray())
+ : BinaryFormat.decode(protobuf.getSlimeSummaries().toByteArray()).get();
var errors = root.field("errors");
boolean hasErrors = errors.valid() && (errors.entries() > 0);
if (hasErrors) {
diff --git a/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java
index 80a41ffdf22..b8be1dc210b 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java
@@ -70,8 +70,8 @@ public class FederationSearcher extends ForkingSearcher {
private static final Logger log = Logger.getLogger(FederationSearcher.class.getName());
/** The name of the query property containing the source name added to the query to each source by this */
- public final static CompoundName SOURCENAME = new CompoundName("sourceName");
- public final static CompoundName PROVIDERNAME = new CompoundName("providerName");
+ public static final CompoundName SOURCENAME = CompoundName.from("sourceName");
+ public static final CompoundName PROVIDERNAME = CompoundName.from("providerName");
public static final String FEDERATION = "Federation";
public static final String LOG_COUNT_PREFIX = "count_";
@@ -686,33 +686,6 @@ public class FederationSearcher extends ForkingSearcher {
}
- private static class CompoundKey {
-
- private final String sourceName;
- private final String propertyName;
-
- CompoundKey(String sourceName, String propertyName) {
- this.sourceName = sourceName;
- this.propertyName = propertyName;
- }
-
- @Override
- public int hashCode() {
- return sourceName.hashCode() ^ propertyName.hashCode();
- }
-
- @Override
- public boolean equals(Object o) {
- CompoundKey rhs = (CompoundKey) o;
- return sourceName.equals(rhs.sourceName) && propertyName.equals(rhs.propertyName);
- }
-
- @Override
- public String toString() {
- return sourceName + '.' + propertyName;
- }
- }
-
private static class Window {
private final int hits;
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingQueryParser.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingQueryParser.java
index 54194221958..180687d5274 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingQueryParser.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingQueryParser.java
@@ -38,13 +38,13 @@ import java.util.TimeZone;
public class GroupingQueryParser extends Searcher {
public static final String SELECT_PARAMETER_PARSING = "SelectParameterParsing";
- public static final CompoundName PARAM_CONTINUE = new CompoundName("continue");
- public static final CompoundName PARAM_REQUEST = new CompoundName(Select.SELECT);
- public static final CompoundName PARAM_TIMEZONE = new CompoundName("timezone");
- @Beta public static final CompoundName PARAM_DEFAULT_MAX_HITS = new CompoundName("grouping.defaultMaxHits");
- @Beta public static final CompoundName PARAM_DEFAULT_MAX_GROUPS = new CompoundName("grouping.defaultMaxGroups");
- @Beta public static final CompoundName PARAM_DEFAULT_PRECISION_FACTOR = new CompoundName("grouping.defaultPrecisionFactor");
- @Beta public static final CompoundName GROUPING_GLOBAL_MAX_GROUPS = new CompoundName("grouping.globalMaxGroups");
+ public static final CompoundName PARAM_CONTINUE = CompoundName.from("continue");
+ public static final CompoundName PARAM_REQUEST = CompoundName.from(Select.SELECT);
+ public static final CompoundName PARAM_TIMEZONE = CompoundName.from("timezone");
+ @Beta public static final CompoundName PARAM_DEFAULT_MAX_HITS = CompoundName.from("grouping.defaultMaxHits");
+ @Beta public static final CompoundName PARAM_DEFAULT_MAX_GROUPS = CompoundName.from("grouping.defaultMaxGroups");
+ @Beta public static final CompoundName PARAM_DEFAULT_PRECISION_FACTOR = CompoundName.from("grouping.defaultPrecisionFactor");
+ @Beta public static final CompoundName GROUPING_GLOBAL_MAX_GROUPS = CompoundName.from("grouping.globalMaxGroups");
private static final ThreadLocal<ZoneCache> zoneCache = new ThreadLocal<>();
@Override
@@ -121,7 +121,6 @@ public class GroupingQueryParser extends Searcher {
return val != null ? OptionalDouble.of(val) : OptionalDouble.empty();
}
- @SuppressWarnings("serial")
private static class ZoneCache extends LinkedHashMap<String, TimeZone> {
ZoneCache() {
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java
index 35cf72d6124..878fbbb733d 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java
@@ -37,7 +37,7 @@ import static com.yahoo.search.grouping.GroupingQueryParser.SELECT_PARAMETER_PAR
public class GroupingValidator extends Searcher {
public static final String GROUPING_VALIDATED = "GroupingValidated";
- public static final CompoundName PARAM_ENABLED = new CompoundName("validate_" + GroupingQueryParser.PARAM_REQUEST);
+ public static final CompoundName PARAM_ENABLED = CompoundName.from("validate_" + GroupingQueryParser.PARAM_REQUEST);
private final HashMap<String, AttributesConfig.Attribute> attributes = new HashMap<>();
private final String clusterName;
private final boolean enabled;
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/UniqueGroupingSearcher.java b/container-search/src/main/java/com/yahoo/search/grouping/UniqueGroupingSearcher.java
index a1446367f79..27d8a76511d 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/UniqueGroupingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/UniqueGroupingSearcher.java
@@ -42,7 +42,7 @@ import java.util.logging.Logger;
@Before(PhaseNames.TRANSFORMED_QUERY)
public class UniqueGroupingSearcher extends Searcher {
- public static final CompoundName PARAM_UNIQUE = new CompoundName("unique");
+ public static final CompoundName PARAM_UNIQUE = CompoundName.from("unique");
private static final Logger log = Logger.getLogger(UniqueGroupingSearcher.class.getName());
private static final HitOrderer NOP_ORDERER = new HitOrderer() {
@@ -144,17 +144,13 @@ public class UniqueGroupingSearcher extends Searcher {
for (Sorting.FieldOrder fieldOrder : sortingSpec.fieldOrders()) {
Sorting.Order sortOrder = fieldOrder.getSortOrder();
switch (sortOrder) {
- case ASCENDING:
- case UNDEFINED:
- // When we want ascending order, the hit with the smallest value should come first (and be surfaced).
- orderingClause.add(new MinAggregator(new AttributeValue(fieldOrder.getFieldName())));
- break;
- case DESCENDING:
- // When we sort in descending order, the hit with the largest value should come first (and be surfaced).
- orderingClause.add(new NegFunction(new MaxAggregator(new AttributeValue(fieldOrder.getFieldName()))));
- break;
- default:
- throw new UnsupportedOperationException("Can not handle sort order " + sortOrder + ".");
+ case ASCENDING, UNDEFINED ->
+ // When we want ascending order, the hit with the smallest value should come first (and be surfaced).
+ orderingClause.add(new MinAggregator(new AttributeValue(fieldOrder.getFieldName())));
+ case DESCENDING ->
+ // When we sort in descending order, the hit with the largest value should come first (and be surfaced).
+ orderingClause.add(new NegFunction(new MaxAggregator(new AttributeValue(fieldOrder.getFieldName()))));
+ default -> throw new UnsupportedOperationException("Can not handle sort order " + sortOrder + ".");
}
}
return orderingClause;
@@ -170,18 +166,13 @@ public class UniqueGroupingSearcher extends Searcher {
GroupingExpression groupingClause = null;
for (Sorting.FieldOrder fieldOrder : sortingSpec.fieldOrders()) {
Sorting.Order sortOrder = fieldOrder.getSortOrder();
- switch (sortOrder) {
- case ASCENDING:
- case UNDEFINED:
- groupingClause = new AttributeValue(fieldOrder.getFieldName());
- break;
- case DESCENDING:
- // To sort descending, just take the negative. This is the most common case
- groupingClause = new NegFunction(new AttributeValue(fieldOrder.getFieldName()));
- break;
- default:
- throw new UnsupportedOperationException("Can not handle sort order " + sortOrder + ".");
- }
+ groupingClause = switch (sortOrder) {
+ case ASCENDING, UNDEFINED -> new AttributeValue(fieldOrder.getFieldName());
+ case DESCENDING ->
+ // To sort descending, just take the negative. This is the most common case
+ new NegFunction(new AttributeValue(fieldOrder.getFieldName()));
+ default -> throw new UnsupportedOperationException("Can not handle sort order " + sortOrder + ".");
+ };
}
return groupingClause;
}
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/result/FlatteningSearcher.java b/container-search/src/main/java/com/yahoo/search/grouping/result/FlatteningSearcher.java
index e56b88c3d3e..027ba92f587 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/result/FlatteningSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/result/FlatteningSearcher.java
@@ -22,7 +22,7 @@ import java.util.Iterator;
@Before(GroupingExecutor.COMPONENT_NAME)
public class FlatteningSearcher extends Searcher {
- private final CompoundName flatten = CompoundName.fromComponents("grouping", "flatten");
+ private final CompoundName flatten = CompoundName.from("grouping.flatten");
@Override
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java b/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java
index 2ba33f60ea1..c85dbed83c8 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/vespa/GroupingExecutor.java
@@ -379,7 +379,7 @@ public class GroupingExecutor extends Searcher {
}
private static CompoundName newCompoundName(String name) {
- return new CompoundName(GroupingExecutor.class.getName() + "." + name);
+ return CompoundName.from(GroupingExecutor.class.getName() + "." + name);
}
private static class RequestContext {
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 fac6c598e4b..3b4d15f788f 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
@@ -75,8 +75,8 @@ public class SearchHandler extends LoggingRequestHandler {
// max number of threads for the executor for this handler
private final int maxThreads;
- private static final CompoundName DETAILED_TIMING_LOGGING = new CompoundName("trace.timingDetails");
- private static final CompoundName FORCE_TIMESTAMPS = new CompoundName("trace.timestamps");
+ private static final CompoundName DETAILED_TIMING_LOGGING = CompoundName.from("trace.timingDetails");
+ private static final CompoundName FORCE_TIMESTAMPS = CompoundName.from("trace.timestamps");
/** Event name for number of connections to the search subsystem */
private static final String SEARCH_CONNECTIONS = "search_connections";
diff --git a/container-search/src/main/java/com/yahoo/search/intent/model/IntentModel.java b/container-search/src/main/java/com/yahoo/search/intent/model/IntentModel.java
index 9aafd2c4693..0c4b22fbbf2 100644
--- a/container-search/src/main/java/com/yahoo/search/intent/model/IntentModel.java
+++ b/container-search/src/main/java/com/yahoo/search/intent/model/IntentModel.java
@@ -5,7 +5,12 @@ import com.yahoo.search.Query;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.text.interpretation.Interpretation;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* This is the root node of an intent model.
@@ -19,9 +24,9 @@ import java.util.*;
public class IntentModel extends ParentNode<InterpretationNode> {
/** The name of the property carrying the intent model string: intentModel */
- public static final CompoundName intentModelStringName=new CompoundName("intentModel");
+ public static final CompoundName intentModelStringName = CompoundName.from("intentModel");
/** The name of the property carrying the intent model object: IntentModel */
- public static final CompoundName intentModelObjectName=new CompoundName("IntentModel");
+ public static final CompoundName intentModelObjectName = CompoundName.from("IntentModel");
private static final InterpretationNodeComparator inodeComp = new InterpretationNodeComparator();
@@ -45,7 +50,7 @@ public class IntentModel extends ParentNode<InterpretationNode> {
/** Sort interpretations by descending score order */
public void sortChildren() {
- Collections.sort(children(), inodeComp);
+ children().sort(inodeComp);
}
/**
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 c23627accf4..5fef1821de2 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
@@ -72,13 +72,13 @@ import java.util.Map;
public class PageTemplateSearcher extends Searcher {
/** The name of the query property containing the resolved candidate page template list */
- public static final CompoundName pagePageTemplateListName=new CompoundName("page.PageTemplateList");
+ public static final CompoundName pagePageTemplateListName = CompoundName.from("page.PageTemplateList");
/** The name of the query property containing a list of candidate pages to consider */
- public static final CompoundName pageIdListName=new CompoundName("page.idList");
+ public static final CompoundName pageIdListName = CompoundName.from("page.idList");
/** The name of the query property containing the page id to use */
- public static final CompoundName pageIdName=new CompoundName("page.id");
+ public static final CompoundName pageIdName = CompoundName.from("page.id");
/** The name of the query property containing the resolver id to use */
- public static final CompoundName pageResolverName=new CompoundName("page.resolver");
+ public static final CompoundName pageResolverName = CompoundName.from("page.resolver");
private final ResolverRegistry resolverRegistry;
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 190ad675015..09b2f394f20 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
@@ -71,13 +71,13 @@ public class Model implements Cloneable {
argumentType.addField(new FieldDescription(SEARCH_PATH, "string", "searchpath"));
argumentType.addField(new FieldDescription(RESTRICT, "string", "restrict"));
argumentType.freeze();
- argumentTypeName = new CompoundName(argumentType.getId().getName());
+ argumentTypeName = CompoundName.from(argumentType.getId().getName());
}
public static QueryProfileType getArgumentType() { return argumentType; }
/** The name of the query property used for generating hit count estimate queries. */
- public static final CompoundName ESTIMATE = new CompoundName("hitcountestimate"); // TODO: Cleanup
+ public static final CompoundName ESTIMATE = CompoundName.from("hitcountestimate"); // TODO: Cleanup
private String encoding = null;
private String queryString = "";
diff --git a/container-search/src/main/java/com/yahoo/search/query/Ranking.java b/container-search/src/main/java/com/yahoo/search/query/Ranking.java
index e8738a19412..5426268d173 100644
--- a/container-search/src/main/java/com/yahoo/search/query/Ranking.java
+++ b/container-search/src/main/java/com/yahoo/search/query/Ranking.java
@@ -27,7 +27,7 @@ import java.util.Objects;
public class Ranking implements Cloneable {
/** An alias for listing features */
- public static final CompoundName RANKFEATURES = new CompoundName("rankfeatures");
+ public static final CompoundName RANKFEATURES = CompoundName.from("rankfeatures");
/** The type representing the property arguments consumed by this */
private static final QueryProfileType argumentType;
@@ -70,7 +70,7 @@ public class Ranking implements Cloneable {
argumentType.addField(new FieldDescription(FEATURES, "query-profile", "rankfeature input")); // Repeated at the end of RankFeatures
argumentType.addField(new FieldDescription(PROPERTIES, "query-profile", "rankproperty"));
argumentType.freeze();
- argumentTypeName = new CompoundName(argumentType.getId().getName());
+ argumentTypeName = CompoundName.from(argumentType.getId().getName());
}
public static QueryProfileType getArgumentType() { return argumentType; }
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java
index ad9d3f4c1a5..ae531c67dd1 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java
@@ -169,7 +169,7 @@ public class CompiledQueryProfile extends AbstractComponent implements Cloneable
}
public final Object get(String name) {
- return get(name, Collections.emptyMap());
+ return get(name, Map.of());
}
public final Object get(String name, Map<String, String> context) {
return get(name, context, new QueryProfileProperties(this));
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
index 8fdbf8b2281..719a5a2c281 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
@@ -64,7 +64,7 @@ public class FieldDescription implements Comparable<FieldDescription> {
}
public FieldDescription(String name, FieldType type, String aliases, boolean mandatory, boolean overridable) {
- this(new CompoundName(name), type, aliases, mandatory, overridable);
+ this(CompoundName.from(name), type, aliases, mandatory, overridable);
}
/**
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
index 3da2ad53f9a..9cbfe5b7112 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
@@ -52,7 +52,7 @@ public class QueryProfileType extends FreezableSimpleComponent {
private QueryProfileType(ComponentId id, Map<String, FieldDescription> fields, List<QueryProfileType> inherited) {
super(id);
QueryProfile.validateName(id.getName());
- componentIdAsCompoundName = new CompoundName(getId().getName());
+ componentIdAsCompoundName = CompoundName.from(getId().getName());
this.fields = fields;
this.inherited = inherited;
}
@@ -318,10 +318,9 @@ public class QueryProfileType extends FreezableSimpleComponent {
QueryProfileType type = null;
FieldDescription fieldDescription = getField(name);
if (fieldDescription != null) {
- if ( ! (fieldDescription.getType() instanceof QueryProfileFieldType))
+ if ( ! (fieldDescription.getType() instanceof QueryProfileFieldType fieldType))
throw new IllegalArgumentException("Cannot use name '" + name + "' as a prefix because it is " +
"already a " + fieldDescription.getType());
- QueryProfileFieldType fieldType = (QueryProfileFieldType) fieldDescription.getType();
type = fieldType.getQueryProfileType();
}
@@ -399,8 +398,7 @@ public class QueryProfileType extends FreezableSimpleComponent {
@Override
public boolean equals(Object o) {
if (o == this) return true;
- if ( ! (o instanceof QueryProfileType)) return false;
- QueryProfileType other = (QueryProfileType)o;
+ if ( ! (o instanceof QueryProfileType other)) return false;
return other.getId().equals(this.getId());
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/DefaultProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/DefaultProperties.java
index 221368afeb6..6ccf4792efb 100644
--- a/container-search/src/main/java/com/yahoo/search/query/properties/DefaultProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/properties/DefaultProperties.java
@@ -16,9 +16,9 @@ import java.util.Map;
*/
public final class DefaultProperties extends Properties {
- public static final CompoundName MAX_OFFSET = new CompoundName("maxOffset");
- public static final CompoundName MAX_HITS = new CompoundName("maxHits");
- public static final CompoundName MAX_QUERY_ITEMS = new CompoundName("maxQueryItems");
+ public static final CompoundName MAX_OFFSET = CompoundName.from("maxOffset");
+ public static final CompoundName MAX_HITS = CompoundName.from("maxHits");
+ public static final CompoundName MAX_QUERY_ITEMS = CompoundName.from("maxQueryItems");
public static final QueryProfileType argumentType = new QueryProfileType("DefaultProperties");
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/SubProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/SubProperties.java
index 42fb4e44040..4fc9dfa03cd 100644
--- a/container-search/src/main/java/com/yahoo/search/query/properties/SubProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/properties/SubProperties.java
@@ -10,14 +10,16 @@ import java.util.Map;
* A wrapper around a chain of property objects that prefixes all gets/sets with a given path
*
* @author Arne Bergene Fossaa
+ * @deprecated Unused and will go away on vespa 9
*/
+@Deprecated (forRemoval = true)
public class SubProperties extends com.yahoo.search.query.Properties {
final private CompoundName pathPrefix;
final private Properties parent;
public SubProperties(String pathPrefix, Properties properties) {
- this(new CompoundName(pathPrefix),properties);
+ this(CompoundName.from(pathPrefix), properties);
}
public SubProperties(CompoundName pathPrefix, Properties properties) {
diff --git a/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java b/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java
index 30ee2f473b7..c49b14f0978 100644
--- a/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java
+++ b/container-search/src/main/java/com/yahoo/search/query/ranking/SoftTimeout.java
@@ -24,8 +24,7 @@ public class SoftTimeout implements Cloneable {
public static final String TAILCOST = "tailcost";
/** The full property name for turning softtimeout on or off */
- public static final CompoundName enableProperty =
- CompoundName.fromComponents(Ranking.RANKING, Ranking.SOFTTIMEOUT, ENABLE);
+ public static final CompoundName enableProperty = CompoundName.from(Ranking.RANKING + "." + Ranking.SOFTTIMEOUT + "." + ENABLE);
static {
argumentType = new QueryProfileType(Ranking.SOFTTIMEOUT);
diff --git a/container-search/src/main/java/com/yahoo/search/query/rewrite/RewriterConstants.java b/container-search/src/main/java/com/yahoo/search/query/rewrite/RewriterConstants.java
index b0fce45de46..eeb8b675ae1 100644
--- a/container-search/src/main/java/com/yahoo/search/query/rewrite/RewriterConstants.java
+++ b/container-search/src/main/java/com/yahoo/search/query/rewrite/RewriterConstants.java
@@ -42,7 +42,7 @@ public class RewriterConstants {
public static final String REWRITER_CHAIN = "QRWChain";
/** Name for rewrite metadata retrieval from query properties */
- public static final CompoundName REWRITE_META = new CompoundName("RewriteMeta");
+ public static final CompoundName REWRITE_META = CompoundName.from("RewriteMeta");
/** Name for rewritten field retrieval from query properties */
public static final String REWRITTEN = "Rewritten";
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/BooleanSearcher.java b/container-search/src/main/java/com/yahoo/search/querytransform/BooleanSearcher.java
index f43be20e0ac..91315fe1bb3 100644
--- a/container-search/src/main/java/com/yahoo/search/querytransform/BooleanSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/querytransform/BooleanSearcher.java
@@ -28,9 +28,9 @@ import static com.yahoo.yolean.Exceptions.toMessageString;
@Provides(BooleanSearcher.PREDICATE)
public class BooleanSearcher extends Searcher {
- private static final CompoundName FIELD = new CompoundName("boolean.field");
- private static final CompoundName ATTRIBUTES = new CompoundName("boolean.attributes");
- private static final CompoundName RANGE_ATTRIBUTES = new CompoundName("boolean.rangeAttributes");
+ private static final CompoundName FIELD = CompoundName.from("boolean.field");
+ private static final CompoundName ATTRIBUTES = CompoundName.from("boolean.attributes");
+ private static final CompoundName RANGE_ATTRIBUTES = CompoundName.from("boolean.rangeAttributes");
public static final String PREDICATE = "predicate";
@Override
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/SortingDegrader.java b/container-search/src/main/java/com/yahoo/search/querytransform/SortingDegrader.java
index 75b06c29193..81881685a1d 100644
--- a/container-search/src/main/java/com/yahoo/search/querytransform/SortingDegrader.java
+++ b/container-search/src/main/java/com/yahoo/search/querytransform/SortingDegrader.java
@@ -41,9 +41,9 @@ public class SortingDegrader extends Searcher {
/** Set this to false in query.properties to turn off degrading. Default: on */
// (this is not called ranking.sorting.degrading because it should not be part of the query object model
- public static final CompoundName DEGRADING = new CompoundName("sorting.degrading");
+ public static final CompoundName DEGRADING = CompoundName.from("sorting.degrading");
- public static final CompoundName PAGINATION = new CompoundName("to_be_removed_pagination");
+ public static final CompoundName PAGINATION = CompoundName.from("to_be_removed_pagination");
@Override
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java b/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java
index 89245eaf137..bfac668b6c4 100644
--- a/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java
@@ -63,12 +63,12 @@ public class WandSearcher extends Searcher {
*/
private static class InputResolver {
- private static final CompoundName WAND_FIELD = new CompoundName("wand.field");
- private static final CompoundName WAND_TOKENS = new CompoundName("wand.tokens");
- private static final CompoundName WAND_HEAP_SIZE = new CompoundName("wand.heapSize");
- private static final CompoundName WAND_TYPE = new CompoundName("wand.type");
- private static final CompoundName WAND_SCORE_THRESHOLD = new CompoundName("wand.scoreThreshold");
- private static final CompoundName WAND_THRESHOLD_BOOST_FACTOR = new CompoundName("wand.thresholdBoostFactor");
+ private static final CompoundName WAND_FIELD = CompoundName.from("wand.field");
+ private static final CompoundName WAND_TOKENS = CompoundName.from("wand.tokens");
+ private static final CompoundName WAND_HEAP_SIZE = CompoundName.from("wand.heapSize");
+ private static final CompoundName WAND_TYPE = CompoundName.from("wand.type");
+ private static final CompoundName WAND_SCORE_THRESHOLD = CompoundName.from("wand.scoreThreshold");
+ private static final CompoundName WAND_THRESHOLD_BOOST_FACTOR = CompoundName.from("wand.thresholdBoostFactor");
private final String fieldName;
private final WandType wandType;
private final Map<Object, Integer> tokens;
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java b/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java
index 2d6e059342e..9aa7a9d998d 100644
--- a/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java
@@ -21,8 +21,8 @@ import com.yahoo.yolean.chain.After;
*/
@After(MinimalQueryInserter.EXTERNAL_YQL)
public class WeakAndReplacementSearcher extends Searcher {
- static final CompoundName WEAKAND_REPLACE = new CompoundName("weakAnd.replace");
- static final CompoundName WAND_HITS = new CompoundName("wand.hits");
+ static final CompoundName WEAKAND_REPLACE = CompoundName.from("weakAnd.replace");
+ static final CompoundName WAND_HITS = CompoundName.from("wand.hits");
@Override public Result search(Query query, Execution execution) {
if (!query.properties().getBoolean(WEAKAND_REPLACE)) {
diff --git a/container-search/src/main/java/com/yahoo/search/ranking/GlobalPhaseRanker.java b/container-search/src/main/java/com/yahoo/search/ranking/GlobalPhaseRanker.java
index 2c6ab9e9367..dd419d69315 100644
--- a/container-search/src/main/java/com/yahoo/search/ranking/GlobalPhaseRanker.java
+++ b/container-search/src/main/java/com/yahoo/search/ranking/GlobalPhaseRanker.java
@@ -4,11 +4,14 @@ package com.yahoo.search.ranking;
import com.yahoo.component.annotation.Inject;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
+import com.yahoo.search.query.Sorting;
import com.yahoo.search.ranking.RankProfilesEvaluator.GlobalPhaseData;
+import com.yahoo.search.result.ErrorMessage;
import com.yahoo.tensor.Tensor;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.function.Supplier;
import java.util.logging.Logger;
@@ -20,14 +23,25 @@ public class GlobalPhaseRanker {
@Inject
public GlobalPhaseRanker(RankProfilesEvaluatorFactory factory) {
this.factory = factory;
- logger.info("using factory: " + factory);
+ logger.fine(() -> "Using factory: " + factory);
}
- public void process(Query query, Result result, String schema) {
- String rankProfile = query.getRanking().getProfile();
- GlobalPhaseData data = factory.evaluatorForSchema(schema)
- .flatMap(evaluator -> evaluator.getGlobalPhaseData(rankProfile))
- .orElse(null);
+ public Optional<ErrorMessage> validateNoSorting(Query query, String schema) {
+ var data = globalPhaseDataFor(query, schema).orElse(null);
+ if (data == null) return Optional.empty();
+ var sorting = query.getRanking().getSorting();
+ if (sorting == null || sorting.fieldOrders() == null) return Optional.empty();
+ for (var fieldOrder : sorting.fieldOrders()) {
+ if (!fieldOrder.getSorter().getName().equals("[rank]")
+ || fieldOrder.getSortOrder() != Sorting.Order.DESCENDING) {
+ return Optional.of(ErrorMessage.createIllegalQuery("Sorting is not supported with global phase"));
+ }
+ }
+ return Optional.empty();
+ }
+
+ public void rerankHits(Query query, Result result, String schema) {
+ var data = globalPhaseDataFor(query, schema).orElse(null);
if (data == null) return;
var functionEvaluatorSource = data.functionEvaluatorSource();
var prepared = findFromQuery(query, data.needInputs());
@@ -45,6 +59,11 @@ public class GlobalPhaseRanker {
ResultReranker.rerankHits(result, new HitRescorer(supplier), rerankCount);
}
+ private Optional<GlobalPhaseData> globalPhaseDataFor(Query query, String schema) {
+ return factory.evaluatorForSchema(schema)
+ .flatMap(evaluator -> evaluator.getGlobalPhaseData(query.getRanking().getProfile()));
+ }
+
record NameAndValue(String name, Tensor value) { }
/* do this only once per query: */
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
index 44620179c1d..b36c8788877 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
@@ -76,10 +76,10 @@ import static com.fasterxml.jackson.databind.SerializationFeature.FLUSH_AFTER_WR
// NOTE: The JSON format is a public API. If new elements are added be sure to update the reference doc.
public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
- private static final CompoundName WRAP_DEEP_MAPS = new CompoundName("renderer.json.jsonMaps");
- private static final CompoundName WRAP_WSETS = new CompoundName("renderer.json.jsonWsets");
- private static final CompoundName DEBUG_RENDERING_KEY = new CompoundName("renderer.json.debug");
- private static final CompoundName JSON_CALLBACK = new CompoundName("jsoncallback");
+ private static final CompoundName WRAP_DEEP_MAPS = CompoundName.from("renderer.json.jsonMaps");
+ private static final CompoundName WRAP_WSETS = CompoundName.from("renderer.json.jsonWsets");
+ private static final CompoundName DEBUG_RENDERING_KEY = CompoundName.from("renderer.json.debug");
+ private static final CompoundName JSON_CALLBACK = CompoundName.from("jsoncallback");
// if this must be optimized, simply use com.fasterxml.jackson.core.SerializableString
private static final String BUCKET_LIMITS = "limits";
diff --git a/container-search/src/main/java/com/yahoo/search/searchers/CacheControlSearcher.java b/container-search/src/main/java/com/yahoo/search/searchers/CacheControlSearcher.java
index a4f03b088f2..29e8afa41ac 100644
--- a/container-search/src/main/java/com/yahoo/search/searchers/CacheControlSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/searchers/CacheControlSearcher.java
@@ -32,9 +32,9 @@ import com.yahoo.search.searchchain.Execution;
*/
public class CacheControlSearcher extends Searcher {
- private static final CompoundName cachecontrolNocache=new CompoundName("cachecontrol.nocache");
- private static final CompoundName cachecontrolMaxage=new CompoundName("cachecontrol.maxage");
- private static final CompoundName cachecontrolStaleage=new CompoundName("cachecontrol.staleage");
+ private static final CompoundName cachecontrolNocache=CompoundName.from("cachecontrol.nocache");
+ private static final CompoundName cachecontrolMaxage=CompoundName.from("cachecontrol.maxage");
+ private static final CompoundName cachecontrolStaleage=CompoundName.from("cachecontrol.staleage");
public static final String CACHE_CONTROL_HEADER = "Cache-Control";
diff --git a/container-search/src/main/java/com/yahoo/search/searchers/ConnectionControlSearcher.java b/container-search/src/main/java/com/yahoo/search/searchers/ConnectionControlSearcher.java
index 90cb05be1f8..18588b2026d 100644
--- a/container-search/src/main/java/com/yahoo/search/searchers/ConnectionControlSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/searchers/ConnectionControlSearcher.java
@@ -49,7 +49,7 @@ public class ConnectionControlSearcher extends Searcher {
private final LongSupplier clock;
- private static final CompoundName KEEPALIVE_MAXLIFETIMESECONDS = new CompoundName("connectioncontrol.maxlifetime");
+ private static final CompoundName KEEPALIVE_MAXLIFETIMESECONDS = CompoundName.from("connectioncontrol.maxlifetime");
private static final String HTTP_CONNECTION_HEADER_NAME = "Connection";
private static final String HTTP_CONNECTION_CLOSE_ARGUMENT = "Close";
diff --git a/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java b/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java
index cf81f62f64d..35a3c86f763 100755
--- a/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java
@@ -54,11 +54,11 @@ public class RateLimitingSearcher extends Searcher {
/** Constant containing the name this Provides - "rateLimiting", for ordering constraints */
public static final String RATE_LIMITING = "rateLimiting";
- public static final CompoundName idKey = new CompoundName("rate.id");
- public static final CompoundName costKey = new CompoundName("rate.cost");
- public static final CompoundName quotaKey = new CompoundName("rate.quota");
- public static final CompoundName idDimensionKey = new CompoundName("rate.idDimension");
- public static final CompoundName dryRunKey = new CompoundName("rate.dryRun");
+ public static final CompoundName idKey = CompoundName.from("rate.id");
+ public static final CompoundName costKey = CompoundName.from("rate.cost");
+ public static final CompoundName quotaKey = CompoundName.from("rate.quota");
+ public static final CompoundName idDimensionKey = CompoundName.from("rate.idDimension");
+ public static final CompoundName dryRunKey = CompoundName.from("rate.dryRun");
private static final String requestsOverQuotaMetricName = "requestsOverQuota";
diff --git a/container-search/src/main/java/com/yahoo/search/yql/FieldFiller.java b/container-search/src/main/java/com/yahoo/search/yql/FieldFiller.java
index 833c1251a7b..6961a189d22 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/FieldFiller.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/FieldFiller.java
@@ -27,7 +27,7 @@ public class FieldFiller extends Searcher {
private final Set<String> intersectionOfAttributes;
private final SchemaInfo schemaInfo;
- public static final CompoundName FIELD_FILLER_DISABLE = new CompoundName("FieldFiller.disable");
+ public static final CompoundName FIELD_FILLER_DISABLE = CompoundName.from("FieldFiller.disable");
public FieldFiller(SchemaInfo schemaInfo) {
this.schemaInfo = schemaInfo;
diff --git a/container-search/src/main/java/com/yahoo/search/yql/FieldFilter.java b/container-search/src/main/java/com/yahoo/search/yql/FieldFilter.java
index 8cc6a1b42b9..df9722d3214 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/FieldFilter.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/FieldFilter.java
@@ -2,13 +2,11 @@
package com.yahoo.search.yql;
import java.util.Iterator;
-import java.util.Map.Entry;
import java.util.Set;
import com.yahoo.api.annotations.Beta;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.component.chain.dependencies.Before;
-import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
@@ -27,7 +25,7 @@ import com.yahoo.search.searchchain.Execution;
@Before("com.yahoo.search.yql.FieldFiller")
public class FieldFilter extends Searcher {
- public static final CompoundName FIELD_FILTER_DISABLE = new CompoundName("FieldFilter.disable");
+ public static final CompoundName FIELD_FILTER_DISABLE = CompoundName.from("FieldFilter.disable");
/** Fields that should be kept even if not explicitly requested */
private static final Set<String> syntheticFields = Set.of("matchfeatures", "rankfeatures", "summaryfeatures");
diff --git a/container-search/src/main/java/com/yahoo/search/yql/MinimalQueryInserter.java b/container-search/src/main/java/com/yahoo/search/yql/MinimalQueryInserter.java
index e844bac21e8..ee4f931d532 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/MinimalQueryInserter.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/MinimalQueryInserter.java
@@ -39,10 +39,10 @@ public class MinimalQueryInserter extends Searcher {
public static final String EXTERNAL_YQL = "ExternalYql";
- public static final CompoundName YQL = new CompoundName("yql");
+ public static final CompoundName YQL = CompoundName.from("yql");
- private static final CompoundName MAX_HITS = new CompoundName("maxHits");
- private static final CompoundName MAX_OFFSET = new CompoundName("maxOffset");
+ private static final CompoundName MAX_HITS = CompoundName.from("maxHits");
+ private static final CompoundName MAX_OFFSET = CompoundName.from("maxOffset");
private static final Logger log = Logger.getLogger(MinimalQueryInserter.class.getName());
@Inject
diff --git a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/MetricsSearcher.java b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/MetricsSearcher.java
index ab9da8ccee5..536355ab62d 100644
--- a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/MetricsSearcher.java
+++ b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/MetricsSearcher.java
@@ -22,8 +22,8 @@ import static com.yahoo.vespa.streamingvisitors.VdsStreamingSearcher.STREAMING_S
*/
public class MetricsSearcher extends Searcher {
- private static final CompoundName metricsearcherId=new CompoundName("metricsearcher.id");
- private static final CompoundName streamingLoadtype=new CompoundName("streaming.loadtype");
+ private static final CompoundName metricsearcherId = CompoundName.from("metricsearcher.id");
+ private static final CompoundName streamingLoadtype = CompoundName.from("streaming.loadtype");
private static final Logger log = Logger.getLogger(MetricsSearcher.class.getName());
@@ -43,7 +43,8 @@ public class MetricsSearcher extends Searcher {
public Result search(Query query, Execution execution) {
long timeMs = System.currentTimeMillis();
- /** Backwards compatibility - convert metricsearcher.id to streaming.loadtype */
+ // Backwards compatibility - convert metricsearcher.id to streaming.loadtype
+ // TODO Cleanup at some point
String metricName = query.properties().getString(metricsearcherId);
if (metricName != null) {
query.properties().set(streamingLoadtype, metricName);
diff --git a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcher.java b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcher.java
index ca199f37dd7..524001748c5 100644
--- a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcher.java
@@ -45,9 +45,9 @@ import java.util.logging.Logger;
*/
public class VdsStreamingSearcher extends VespaBackEndSearcher {
- private static final CompoundName streamingUserid = new CompoundName("streaming.userid");
- private static final CompoundName streamingGroupname = new CompoundName("streaming.groupname");
- private static final CompoundName streamingSelection = new CompoundName("streaming.selection");
+ private static final CompoundName streamingUserid = CompoundName.from("streaming.userid");
+ private static final CompoundName streamingGroupname = CompoundName.from("streaming.groupname");
+ private static final CompoundName streamingSelection = CompoundName.from("streaming.selection");
static final String STREAMING_STATISTICS = "streaming.statistics";
private final VisitorFactory visitorFactory;
diff --git a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java
index 85ef10b29f6..70dff6730ff 100644
--- a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java
+++ b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java
@@ -51,13 +51,13 @@ import java.util.logging.Level;
*/
class VdsVisitor extends VisitorDataHandler implements Visitor {
- private static final CompoundName streamingUserid=new CompoundName("streaming.userid");
- private static final CompoundName streamingGroupname=new CompoundName("streaming.groupname");
- private static final CompoundName streamingSelection=new CompoundName("streaming.selection");
- private static final CompoundName streamingFromtimestamp=new CompoundName("streaming.fromtimestamp");
- private static final CompoundName streamingTotimestamp=new CompoundName("streaming.totimestamp");
- private static final CompoundName streamingPriority=new CompoundName("streaming.priority");
- private static final CompoundName streamingMaxbucketspervisitor=new CompoundName("streaming.maxbucketspervisitor");
+ private static final CompoundName streamingUserid = CompoundName.from("streaming.userid");
+ private static final CompoundName streamingGroupname = CompoundName.from("streaming.groupname");
+ private static final CompoundName streamingSelection = CompoundName.from("streaming.selection");
+ private static final CompoundName streamingFromtimestamp = CompoundName.from("streaming.fromtimestamp");
+ private static final CompoundName streamingTotimestamp = CompoundName.from("streaming.totimestamp");
+ private static final CompoundName streamingPriority = CompoundName.from("streaming.priority");
+ private static final CompoundName streamingMaxbucketspervisitor = CompoundName.from("streaming.maxbucketspervisitor");
protected static final int MAX_BUCKETS_PER_VISITOR = 1024;