aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-05-23 13:11:37 +0200
committerGitHub <noreply@github.com>2018-05-23 13:11:37 +0200
commitf14a7189ea46c33fb3469ec1c0fcbb7eb531f32a (patch)
tree364185fc883ca31e9616fba7ad1a1d5f6feca565
parent7243f2edf5d05e128947560539f840658e7648bb (diff)
parent0fa6036254da751e0e38f77c20a419124b8af800 (diff)
Merge pull request #5913 from vespa-engine/revert-5903-bratseth/iterate-over-indexes-not-fields
Revert "Bratseth/iterate over indexes not fields"
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/IndexFacts.java16
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java4
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/CollapsePhraseSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java7
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/NoRankingSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/NonPhrasingSearcher.java16
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/NormalizingSearcher.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java8
-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/searcher/DocumentSourceSearcher.java10
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java12
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java108
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java24
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java9
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java88
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/Context.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java7
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/Template.java6
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/NGramSearcher.java13
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/Templating.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/model/VespaSearchers.java16
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java11
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java35
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java32
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java13
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java13
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java18
-rwxr-xr-xvespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java6
44 files changed, 269 insertions, 282 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java
index 659a07cfd5c..e60aabd24e8 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java
@@ -60,7 +60,7 @@ public class DistributorCluster extends AbstractConfigProducer<Distributor> impl
return s.toString();
}
- private int getGCInterval(ModelElement documentNode) {
+ private int getGCInterval(ModelElement documentNode) throws ParseException {
int gcInterval = 3600;
if (documentNode != null) {
gcInterval = documentNode.getIntegerAttribute("garbage-collection-interval", gcInterval);
diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
index bdf395c1f0b..b899f690ee1 100644
--- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
+++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java
@@ -166,8 +166,8 @@ public class IndexFacts {
}
private Index getIndexFromDocumentTypes(String indexName, List<String> documentTypes) {
- if (indexName == null || indexName.isEmpty())
- indexName = "default";
+ if (indexName==null || indexName.isEmpty())
+ indexName="default";
return getIndexByCanonicNameFromDocumentTypes(indexName, documentTypes);
}
@@ -191,13 +191,6 @@ public class IndexFacts {
return Index.nullIndex;
}
- private Collection<Index> getIndexes(String documentType) {
- if ( ! isInitialized()) return Collections.emptyList();
- SearchDefinition sd = searchDefinitions.get(documentType);
- if (sd == null) return Collections.emptyList();
- return sd.indices().values();
- }
-
/** Calls resolveDocumentTypes(query.getModel().getSources(), query.getModel().getRestrict()) */
private Set<String> resolveDocumentTypes(Query query) {
// Assumption: Search definition name equals document name.
@@ -428,11 +421,6 @@ public class IndexFacts {
return IndexFacts.this.getIndexFromDocumentTypes(indexName, Collections.singletonList(documentType));
}
- /** Returns all the indexes of a given search definition */
- public Collection<Index> getIndexes(String documentType) {
- return IndexFacts.this.getIndexes(documentType);
- }
-
/**
* Returns the canonical form of the index name (Which may be the same as
* the input).
diff --git a/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java b/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java
index 47becde7b19..644cacfa322 100644
--- a/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java
+++ b/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java
@@ -83,7 +83,7 @@ public class SearchDefinition {
}
/** Returns the indices of this as a map */
- public Map<String, Index> indices() {
+ public Map<String,Index> indices() {
return indices;
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java b/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java
index 9d852c8822d..e38c30c25ac 100644
--- a/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java
+++ b/container-search/src/main/java/com/yahoo/prelude/logging/AccessLogEntry.java
@@ -4,10 +4,8 @@ package com.yahoo.prelude.logging;
/**
* Hollow compatibility class for com.yahoo.container.logging.AccessLogEntry.
*
- * @author Steinar Knutsen
- * @deprecated do not use
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
-@Deprecated // TODO: Remove on Vespa 7
public class AccessLogEntry extends com.yahoo.container.logging.AccessLogEntry {
public AccessLogEntry() {
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/CollapsePhraseSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/CollapsePhraseSearcher.java
index 47e5651f64c..abf37c71b76 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/CollapsePhraseSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/CollapsePhraseSearcher.java
@@ -15,11 +15,9 @@ import com.yahoo.search.searchchain.Execution;
/**
* Make single item phrases in query into single word items.
*
- * @author Steinar Knutsen
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
public class CollapsePhraseSearcher extends Searcher {
-
- @Override
public Result search(Query query, Execution execution) {
QueryTree tree = query.getModel().getQueryTree();
Item root = tree.getRoot();
@@ -37,6 +35,7 @@ public class CollapsePhraseSearcher extends Searcher {
return execution.search(query);
}
+
private Item simplifyPhrases(Item root) {
if (root == null) {
return root;
@@ -65,5 +64,4 @@ public class CollapsePhraseSearcher extends Searcher {
else
return root;
}
-
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java
index dd8f4eff666..3d803b322ca 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/IndexCombinatorSearcher.java
@@ -22,15 +22,14 @@ import java.util.*;
* Searcher to rewrite queries to achieve mixed recall between indices and
* memory attributes.
*
- * @author Steinar Knutsen
- * @deprecated do not use
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
@After({PhaseNames.RAW_QUERY, PHRASE_REPLACEMENT})
@Before(PhaseNames.TRANSFORMED_QUERY)
@Provides(IndexCombinatorSearcher.MIXED_RECALL_REWRITE)
-@Deprecated // TODO: Remove on Vespa 7 (not necessary any more)
+// TODO: This is not necessary on Vespa 6, we should probably remove it from the default chain but keep it
+// around until Vespa 6 to avoid breaking those who refer to it.
public class IndexCombinatorSearcher extends Searcher {
-
public static final String MIXED_RECALL_REWRITE = "MixedRecallRewrite";
private static class ArrayComparator implements Comparator<Attribute[]> {
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/NoRankingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/NoRankingSearcher.java
index 7456f33d00f..72c38448936 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/NoRankingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/NoRankingSearcher.java
@@ -1,16 +1,16 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.querytransform;
+
import java.util.List;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.component.chain.dependencies.Before;
-import com.yahoo.search.Query;
-import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.query.Sorting.FieldOrder;
import com.yahoo.search.searchchain.Execution;
+
/**
* Avoid doing relevance calculations if sorting only
* on attributes.
@@ -25,7 +25,7 @@ public class NoRankingSearcher extends Searcher {
private static final String UNRANKED = "unranked";
@Override
- public Result search(Query query, Execution execution) {
+ public com.yahoo.search.Result search(com.yahoo.search.Query query, Execution execution) {
List<FieldOrder> s = (query.getRanking().getSorting() != null) ? query.getRanking().getSorting().fieldOrders() : null;
if (s == null) {
return execution.search(query);
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 ffb1b8a4965..7a548acbff7 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
@@ -5,8 +5,6 @@ import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.component.chain.dependencies.Before;
import com.yahoo.container.QrSearchersConfig;
-import com.yahoo.search.Query;
-import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.searchchain.Execution;
@@ -14,7 +12,7 @@ import com.yahoo.search.searchchain.Execution;
import java.util.List;
/**
- * Detects and removes certain phrases from the query.
+ * <p>Detects and removes certain phrases from the query.</p>
*
* @author bratseth
*/
@@ -54,9 +52,9 @@ public class NonPhrasingSearcher extends Searcher {
}
@Override
- public Result search(Query query, Execution execution) {
- List<PhraseMatcher.Phrase> phrases = phraseMatcher.matchPhrases(query.getModel().getQueryTree().getRoot());
- if (phrases != null && !query.properties().getBoolean(suggestonly, false)) {
+ public com.yahoo.search.Result search(com.yahoo.search.Query query, Execution execution) {
+ List<PhraseMatcher.Phrase> phrases=phraseMatcher.matchPhrases(query.getModel().getQueryTree().getRoot());
+ if (phrases!=null && !query.properties().getBoolean(suggestonly, false)) {
remove(phrases);
query.trace("Removing stop words",true,2);
}
@@ -66,9 +64,9 @@ public class NonPhrasingSearcher extends Searcher {
private void remove(List<PhraseMatcher.Phrase> phrases) {
// Removing the leaf replace phrases first to preserve
// the start index of each replace phrase until removing
- for (int i = phrases.size()-1; i >= 0; i-- ) {
- PhraseMatcher.Phrase phrase = phrases.get(i);
- if (phrase.getLength() < phrase.getOwner().getItemCount()) // Don't removeField all
+ for (int i=phrases.size()-1; i>=0; i-- ) {
+ PhraseMatcher.Phrase phrase= phrases.get(i);
+ if (phrase.getLength()<phrase.getOwner().getItemCount()) // Don't removeField all
phrase.remove();
}
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/NormalizingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/NormalizingSearcher.java
index fdd6ad47a98..02c8ecda60c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/NormalizingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/NormalizingSearcher.java
@@ -11,7 +11,6 @@ import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.IndexFacts.Session;
import com.yahoo.prelude.query.*;
import com.yahoo.prelude.query.WordAlternativesItem.Alternative;
-import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.language.Language;
import com.yahoo.language.Linguistics;
@@ -47,7 +46,7 @@ public class NormalizingSearcher extends Searcher {
}
@Override
- public Result search(Query query, Execution execution) {
+ public com.yahoo.search.Result search(com.yahoo.search.Query query, Execution execution) {
normalize(query, execution.context().getIndexFacts().newSession(query));
return execution.search(query);
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java
index e8e4dc39fd5..f4891489216 100644
--- a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java
@@ -20,15 +20,15 @@ public class PhraseMatcher {
private FSA phraseFSA = null;
- private boolean matchPhraseItems = false;
+ private boolean matchPhraseItems=false;
- private boolean matchSingleItems = false;
+ private boolean matchSingleItems=false;
/** Whether this should ignore regular plural/singular form differences when matching */
- private boolean ignorePluralForm = false;
+ private boolean ignorePluralForm=false;
/** False to matche the longest phrase, true to match <i>all</i> phrases */
- private boolean matchAll = false;
+ private boolean matchAll =false;
/** For null subclass only */
private 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 2f3f4dbd351..d530ec6b45e 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=new CompoundName("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 69331a196a2..4490d3c9b1e 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
@@ -38,7 +38,7 @@ public class RecallSearcher extends Searcher {
private static final CompoundName recallName=new CompoundName("recall");
@Override
- public Result search(Query query, Execution execution) {
+ public com.yahoo.search.Result search(Query query, Execution execution) {
String recall = query.properties().getString(recallName);
if (recall == null) return execution.search(query);
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
index 2f9e81c1607..415ebd7871c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
@@ -27,12 +27,9 @@ import java.util.Set;
* will be returned when attribute prefetch filling is requested.</p>
*
* @author bratseth
- * @deprecated use {@link com.yahoo.search.searchchain.testutil.DocumentSourceSearcher}
*/
@SuppressWarnings({"rawtypes"})
-@Deprecated // TODO: Remove on Vespa 7
public class DocumentSourceSearcher extends Searcher {
-
// as for the SuppressWarnings annotation above, we are inside
// com.yahoo.prelude, this is old stuff, really no point firing off those
// warnings here...
@@ -41,6 +38,7 @@ public class DocumentSourceSearcher extends Searcher {
private Map<Query, Result> completelyFilledResults = new HashMap<>();
private Map<Query, Result> attributeFilledResults = new HashMap<>();
private Map<Query, Result> unFilledResults = new HashMap<>();
+ //private Result defaultUnfilledResult;
/** Time (in ms) at which the index of this searcher was last modified */
long editionTimeStamp=0;
@@ -103,11 +101,11 @@ public class DocumentSourceSearcher extends Searcher {
}
/**
- * Returns a query clone which has source, offset and hits set to null. This is used by access to
+ * Returns a query clone which has offset and hits set to null. This is used by access to
* the maps using the query as key to achieve lookup independent of offset/hits value
*/
- private Query getQueryKeyClone(Query query) {
- Query key = query.clone();
+ private com.yahoo.search.Query getQueryKeyClone(com.yahoo.search.Query query) {
+ com.yahoo.search.Query key=query.clone();
key.setWindow(0,0);
key.getModel().setSources("");
return key;
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 21fa8962da4..71e54c810c2 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
@@ -19,9 +19,10 @@ import java.util.Map;
/**
- * A searcher which does parametrized collapsing.
+ * A searcher which does parametrized collapsing. Based on
+ * SiteCollapsingSearcher. Deprecated - use grouping.
*
- * @author Steinar Knutsen
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
@SuppressWarnings("deprecation")
@After(PhaseNames.RAW_QUERY)
@@ -173,18 +174,17 @@ public class FieldCollapsingSearcher extends Searcher {
}
if (knownCollapses.containsKey(collapseId)) {
- int numHitsThisField = knownCollapses.get(collapseId);
+ int numHitsThisField = knownCollapses.get(collapseId).intValue();
if (numHitsThisField < collapseSize) {
result.hits().add(hit);
++numHitsThisField;
- knownCollapses.put(collapseId, numHitsThisField);
+ knownCollapses.put(collapseId, Integer.valueOf(numHitsThisField));
}
} else {
- knownCollapses.put(collapseId, 1);
+ knownCollapses.put(collapseId, Integer.valueOf(1));
result.hits().add(hit);
}
}
}
-
}
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 2330ca2382a..c18f3d49da3 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
@@ -16,17 +16,16 @@ import java.util.Iterator;
/**
* Save the query in the incoming state to a meta hit in the result.
*
- * @author Steinar Knutsen
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
-public class JSONDebugSearcher extends Searcher {
+public class JSONDebugSearcher extends Searcher {
public static final String JSON_FIELD = "JSON field: ";
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");
- @Override
public Result search(com.yahoo.search.Query query, Execution execution) {
Result r = execution.search(query);
String propertyName = query.properties().getString(PROPERTYNAME);
@@ -54,5 +53,4 @@ public class JSONDebugSearcher extends Searcher {
}
return r;
}
-
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java
index 5c56379efc0..ca87c0c1d46 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java
@@ -78,13 +78,13 @@ public class JuniperSearcher extends Searcher {
@Override
public void fill(Result result, String summaryClass, Execution execution) {
Result workResult = result;
- int worstCase = workResult.getHitCount();
- List<Hit> hits = new ArrayList<>(worstCase);
- for (Iterator<Hit> i = workResult.hits().deepIterator(); i.hasNext();) {
- Hit sniffHit = i.next();
+ final int worstCase = workResult.getHitCount();
+ final List<Hit> hits = new ArrayList<>(worstCase);
+ for (final Iterator<Hit> i = workResult.hits().deepIterator(); i.hasNext();) {
+ final Hit sniffHit = i.next();
if ( ! (sniffHit instanceof FastHit)) continue;
- FastHit hit = (FastHit) sniffHit;
+ final FastHit hit = (FastHit) sniffHit;
if (hit.isFilled(summaryClass)) continue;
hits.add(hit);
@@ -105,46 +105,54 @@ public class JuniperSearcher extends Searcher {
Object searchDefinitionField = hit.getField(MAGIC_FIELD);
if (searchDefinitionField == null) continue;
-
- for (Index index : indexFacts.getIndexes(searchDefinitionField.toString())) {
- if (index.getDynamicSummary() || index.getHighlightSummary()) {
- HitField fieldValue = hit.buildHitField(index.getName(), true, true);
- if (fieldValue != null)
- insertTags(fieldValue, bolding, index.getDynamicSummary());
- }
+ String searchDefinitionName = searchDefinitionField.toString();
+
+ // TODO: Switch to iterate over indexes in the outer loop:
+ //for (Index index : indexFacts.getIndexes(searchDefinitionName())) {
+ // if (index.getDynamicSummary() || index.getHighlightSummary()) {
+ // insertTags(hit.buildHitField(index.getName(), true, true), bolding, index.getDynamicSummary());
+ // }
+ //}
+ for (String fieldName : hit.fields().keySet()) {
+ Index index = indexFacts.getIndex(fieldName, searchDefinitionName);
+ if (index.getDynamicSummary() || index.getHighlightSummary())
+ insertTags(hit.buildHitField(fieldName, true, true), bolding, index.getDynamicSummary());
}
}
}
- private void insertTags(HitField oldProperty, boolean bolding, boolean dynteaser) {
+ private void insertTags(final HitField oldProperty, final boolean bolding, final boolean dynteaser) {
boolean insideHighlight = false;
- for (ListIterator<FieldPart> i = oldProperty.listIterator(); i.hasNext();) {
- FieldPart f = i.next();
- if (f instanceof SeparatorFieldPart)
+ for (final ListIterator<FieldPart> i = oldProperty.listIterator(); i.hasNext();) {
+ final FieldPart f = i.next();
+ if (f instanceof SeparatorFieldPart) {
setSeparatorString(bolding, (SeparatorFieldPart) f);
- if (f.isFinal()) continue;
+ }
+ if (f.isFinal()) {
+ continue;
+ }
- String toQuote = f.getContent();
+ final String toQuote = f.getContent();
List<FieldPart> newFieldParts = null;
int previous = 0;
for (int j = 0; j < toQuote.length(); j++) {
- char key = toQuote.charAt(j);
+ final char key = toQuote.charAt(j);
switch (key) {
- case RAW_HIGHLIGHT_CHAR:
- newFieldParts = initFieldParts(newFieldParts);
- addBolding(bolding, insideHighlight, f, toQuote, newFieldParts, previous, j);
- previous = j + 1;
- insideHighlight = !insideHighlight;
- break;
- case RAW_SEPARATOR_CHAR:
- newFieldParts = initFieldParts(newFieldParts);
- addSeparator(bolding, dynteaser, f, toQuote, newFieldParts,
- previous, j);
- previous = j + 1;
- break;
- default:
- // no action
- break;
+ case RAW_HIGHLIGHT_CHAR:
+ newFieldParts = initFieldParts(newFieldParts);
+ addBolding(bolding, insideHighlight, f, toQuote, newFieldParts, previous, j);
+ previous = j + 1;
+ insideHighlight = !insideHighlight;
+ break;
+ case RAW_SEPARATOR_CHAR:
+ newFieldParts = initFieldParts(newFieldParts);
+ addSeparator(bolding, dynteaser, f, toQuote, newFieldParts,
+ previous, j);
+ previous = j + 1;
+ break;
+ default:
+ // no action
+ break;
}
}
if (previous > 0 && previous < toQuote.length()) {
@@ -152,30 +160,37 @@ public class JuniperSearcher extends Searcher {
}
if (newFieldParts != null) {
i.remove();
- for (Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext();) {
+ for (final Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext();) {
i.add(j.next());
}
}
}
}
- private void setSeparatorString(boolean bolding, SeparatorFieldPart f) {
- if (bolding)
+ private void setSeparatorString(final boolean bolding,final SeparatorFieldPart f) {
+ if (bolding) {
f.setContent(separatorTag);
- else
+ } else {
f.setContent(ELLIPSIS);
+ }
}
- private void addSeparator(boolean bolding, boolean dynteaser, FieldPart f, String toQuote,
- List<FieldPart> newFieldParts, int previous, int j) {
- if (previous != j)
+ private void addSeparator(final boolean bolding, final boolean dynteaser,
+ final FieldPart f, final String toQuote,
+ final List<FieldPart> newFieldParts, final int previous, final int j) {
+ if (previous != j) {
newFieldParts.add(new StringFieldPart(toQuote.substring(previous, j), f.isToken()));
- if (dynteaser)
- newFieldParts.add(bolding ? new SeparatorFieldPart(separatorTag) : new SeparatorFieldPart(ELLIPSIS));
+ }
+ if (dynteaser) {
+ final FieldPart s = (bolding ? new SeparatorFieldPart(separatorTag) : new SeparatorFieldPart(ELLIPSIS));
+ newFieldParts.add(s);
+ }
}
- private void addBolding(boolean bolding, boolean insideHighlight, FieldPart f, String toQuote,
- List<FieldPart> newFieldParts, int previous, int j) {
+ private void addBolding(final boolean bolding,
+ final boolean insideHighlight, final FieldPart f,
+ final String toQuote, final List<FieldPart> newFieldParts,
+ final int previous, final int j) {
if (previous != j) {
newFieldParts.add(new StringFieldPart(toQuote.substring(previous, j), f.isToken()));
}
@@ -194,8 +209,9 @@ public class JuniperSearcher extends Searcher {
}
private List<FieldPart> initFieldParts(List<FieldPart> newFieldParts) {
- if (newFieldParts == null)
+ if (newFieldParts == null) {
newFieldParts = new ArrayList<>();
+ }
return newFieldParts;
}
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 3b2fd596cfa..c47af9e32da 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
@@ -17,7 +17,7 @@ import java.util.*;
*
* <p> For each group, the desired number of hits can be specified. </p>
*
- * @author tonytv
+ * @author tonytv
*/
public class MultipleResultsSearcher extends Searcher {
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 43717ecf6cd..33667349397 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
@@ -34,7 +34,6 @@ import com.yahoo.prelude.Location;
@Before(PhaseNames.TRANSFORMED_QUERY)
@Provides(PosSearcher.POSITION_PARSING)
public class PosSearcher extends Searcher {
-
public static final String POSITION_PARSING = "PositionParsing";
private static final CompoundName posBb = new CompoundName("pos.bb");
@@ -53,7 +52,7 @@ public class PosSearcher extends Searcher {
public final static double km2deg = 1000.000 * 180.0 / (Math.PI * 6356752.0);
public final static double mi2deg = 1609.344 * 180.0 / (Math.PI * 6356752.0);
- @Override
+
public Result search(Query query, Execution execution) {
String bb = query.properties().getString(posBb);
String ll = query.properties().getString(posLl);
@@ -93,8 +92,9 @@ public class PosSearcher extends Searcher {
}
}
catch (IllegalArgumentException e) {
- return new Result(query, ErrorMessage.createInvalidQueryParameter("Error in pos parameters: " +
- Exceptions.toMessageString(e)));
+ // System.err.println("error: "+e);
+ return new Result(query, ErrorMessage.createInvalidQueryParameter(
+ "Error in pos parameters: " + Exceptions.toMessageString(e)));
}
// and finally:
query.getRanking().setLocation(loc);
@@ -102,8 +102,8 @@ public class PosSearcher extends Searcher {
}
private void handleGeoCircle(Query query, String ll, Location target) {
- double ewCoord;
- double nsCoord;
+ double ewCoord = 0;
+ double nsCoord = 0;
try {
DegreesParser parsed = new DegreesParser(ll);
ewCoord = parsed.longitude;
@@ -111,9 +111,9 @@ public class PosSearcher extends Searcher {
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unable to parse lat/long string '" +ll + "'", e);
}
-
String radius = query.properties().getString(posRadius);
- double radiusdegrees;
+ double radiusdegrees = 0.0;
+
if (radius == null) {
radiusdegrees = 50.0 * km2deg;
} else if (radius.endsWith("km")) {
@@ -133,8 +133,8 @@ public class PosSearcher extends Searcher {
private void handleXyCircle(Query query, String xy, Location target) {
- int xcoord;
- int ycoord;
+ int xcoord = 0;
+ int ycoord = 0;
// parse xy
int semipos = xy.indexOf(';');
if (semipos > 0 && semipos < xy.length()) {
@@ -143,9 +143,8 @@ public class PosSearcher extends Searcher {
} else {
throw new IllegalArgumentException("pos.xy must be in the format 'digits;digits' but was: '"+xy+"'");
}
-
String radius = query.properties().getString(posRadius);
- int radiusUnits;
+ int radiusUnits = 0;
if (radius == null) {
radiusUnits = 5000;
} else if (radius.endsWith("km")) {
@@ -166,6 +165,7 @@ public class PosSearcher extends Searcher {
target.setXyCircle(xcoord, ycoord, radiusUnits);
}
+
private static void parseBoundingBox(String bb, Location target) {
BoundingBoxParser parser = new BoundingBoxParser(bb);
target.setBoundingBox(parser.n, parser.s, parser.e, parser.w);
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
index 32efcde6feb..81b948682df 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
@@ -11,20 +11,19 @@ import com.yahoo.search.searchchain.Execution;
/**
* Save the query in the incoming state to a meta hit in the result.
*
- * @author Steinar Knutsen
- * @deprecated do not use
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
-@Deprecated // TODO: Remove on Vespa 7
+
public class QuerySnapshotSearcher extends Searcher {
public Result search(Query query, Execution execution) {
Query q = query.clone();
Result r = execution.search(query);
- Hit h = new Hit("meta:querysnapshot", new Relevance(Double.POSITIVE_INFINITY));
+ Hit h = new Hit("meta:querysnapshot", new Relevance(
+ Double.POSITIVE_INFINITY));
h.setMeta(true);
h.setField("query", q);
r.hits().add(h);
return r;
}
-
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
index 558521a7a8d..4e604dcd226 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
@@ -10,10 +10,8 @@ import com.yahoo.search.searchchain.Execution;
/**
* Ensures hits is 1000 or less and offset is 1000 or less.
*
- * @author Steinar Knutsen
- * @deprecated do not use
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
-@Deprecated // TODO: Remove on Vespa 7
public class QueryValidatingSearcher extends Searcher {
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java
index 5dcc533fb1f..d4cad7f1246 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java
@@ -35,7 +35,6 @@ public class QuotingSearcher extends Searcher {
}
private static class QuoteTable {
-
private final int lowerUncachedBound;
private final int upperUncachedBound;
private final Map<Character, String> quoteMap;
@@ -51,10 +50,12 @@ public class QuotingSearcher extends Searcher {
boolean newIsEmpty = true;
Map<Character, String> newQuoteMap = new HashMap<>();
for (Iterator<?> i = config.character().iterator(); i.hasNext(); ) {
- QrQuotetableConfig.Character character = (QrQuotetableConfig.Character)i.next();
+ QrQuotetableConfig.Character character
+ = (QrQuotetableConfig.Character)i.next();
if (character.ordinal() > 256) {
newIsEmpty = false;
- newQuoteMap.put(new Character((char)character.ordinal()), character.quoting());
+ newQuoteMap.put(new Character((char)character.ordinal()),
+ character.quoting());
newUseMap = true;
if (minOrd == 0 || character.ordinal() < minOrd)
minOrd = character.ordinal();
@@ -63,7 +64,8 @@ public class QuotingSearcher extends Searcher {
}
else {
newIsEmpty = false;
- newLowerTable[character.ordinal()] = character.quoting();
+ newLowerTable[character.ordinal()]
+ = character.quoting();
}
}
lowerUncachedBound = minOrd;
@@ -73,19 +75,22 @@ public class QuotingSearcher extends Searcher {
isEmpty = newIsEmpty;
lowerTable = newLowerTable;
}
-
public String get(char c) {
- if (isEmpty) return null;
-
+ if (isEmpty)
+ return null;
int ord = (int)c;
if (ord < 256) {
return lowerTable[ord];
}
else {
- if ((!useMap) || ord < lowerUncachedBound || ord > upperUncachedBound)
+ if ((!useMap) || ord < lowerUncachedBound
+ || ord > upperUncachedBound)
+ {
return null;
- else
+ }
+ else {
return quoteMap.get(new Character(c));
+ }
}
}
public boolean isEmpty() {
@@ -102,29 +107,35 @@ public class QuotingSearcher extends Searcher {
Result result = execution.search(query);
execution.fill(result);
QuoteTable translations = getQuoteTable();
- if (translations == null || translations.isEmpty()) return result;
-
+ if (translations == null || translations.isEmpty()) {
+ return result;
+ }
for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext(); ) {
Hit h = i.next();
- if (h instanceof FastHit)
- quoteFields((FastHit) h, translations);
+ if (h instanceof FastHit) {
+ quoteProperties((FastHit)h, translations);
+ }
}
return result;
}
- private void quoteFields(FastHit hit, QuoteTable translations) {
- hit.forEachField((fieldName, fieldValue) -> {
- if (fieldValue != null) {
- Class<?> fieldType = fieldValue.getClass();
- if (fieldType.equals(HitField.class))
- quoteField((HitField) fieldValue, translations);
- else if (fieldType.equals(String.class))
- quoteField(hit, fieldName, (String) fieldValue, translations);
+ private void quoteProperties(FastHit hit, QuoteTable translations) {
+ for (Iterator<?> i = ((Set<?>) hit.fields().keySet()).iterator(); i.hasNext(); ) {
+ String propertyName = (String) i.next();
+ Object entry = hit.getField(propertyName);
+ if (entry == null) {
+ continue;
+ }
+ Class<? extends Object> propertyType = entry.getClass();
+ if (propertyType.equals(HitField.class)) {
+ quoteField((HitField) entry, translations);
+ } else if (propertyType.equals(String.class)) {
+ quoteProperty(hit, propertyName, (String)entry, translations);
}
- });
+ }
}
- private void quoteField(Hit hit, String fieldname, String toQuote, QuoteTable translations) {
+ private void quoteProperty(Hit hit, String fieldname, String toQuote, QuoteTable translations) {
List<FieldPart> l = translate(toQuote, translations, true);
if (l != null) {
HitField hf = new HitField(fieldname, toQuote);
@@ -133,11 +144,13 @@ public class QuotingSearcher extends Searcher {
}
}
+
private void quoteField(HitField field, QuoteTable translations) {
for (ListIterator<FieldPart> i = field.listIterator(); i.hasNext(); ) {
FieldPart f = i.next();
- if ( ! f.isFinal()) {
- List<FieldPart> newFieldParts = translate(f.getContent(), translations, f.isToken());
+ if (!f.isFinal()) {
+ List<FieldPart> newFieldParts = translate(f.getContent(), translations,
+ f.isToken());
if (newFieldParts != null) {
i.remove();
for (Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext(); ) {
@@ -148,24 +161,33 @@ public class QuotingSearcher extends Searcher {
}
}
- private List<FieldPart> translate(String toQuote, QuoteTable translations, boolean isToken) {
+ private List<FieldPart> translate(String toQuote, QuoteTable translations,
+ boolean isToken) {
List<FieldPart> newFieldParts = null;
int lastIdx = 0;
for (int i = 0; i < toQuote.length(); i++) {
String quote = translations.get(toQuote.charAt(i));
if (quote != null) {
- if (newFieldParts == null)
+ if (newFieldParts == null) {
newFieldParts = new ArrayList<>();
- if (lastIdx != i)
- newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx, i), isToken));
+ }
+ if (lastIdx != i) {
+ newFieldParts.add(
+ new StringFieldPart(toQuote.substring(lastIdx, i),
+ isToken));
+ }
String initContent = Character.toString(toQuote.charAt(i));
- newFieldParts.add(new ImmutableFieldPart(initContent, quote, isToken));
+ newFieldParts.add(new ImmutableFieldPart(initContent,
+ quote,
+ isToken));
lastIdx = i+1;
}
}
- if (lastIdx > 0 && lastIdx < toQuote.length())
- newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx), isToken));
+ if (lastIdx > 0 && lastIdx < toQuote.length()) {
+ newFieldParts.add(
+ new StringFieldPart(toQuote.substring(lastIdx),
+ isToken));
+ }
return newFieldParts;
}
-
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java
index 9b6f5926b61..2e2c73b6707 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java
@@ -20,7 +20,7 @@ import java.util.Collection;
/**
* Checks that predicate queries don't use values outside the defined upper/lower bounds.
*
- * @author Magnar Nedland
+ * @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
*/
@After(BooleanSearcher.PREDICATE)
public class ValidatePredicateSearcher extends Searcher {
@@ -78,5 +78,4 @@ public class ValidatePredicateSearcher extends Searcher {
@Override
public void onExit() {}
}
-
}
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 bd61de7f783..9de1a5e2a2d 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
@@ -10,7 +10,6 @@ import com.yahoo.log.LogLevel;
import com.yahoo.metrics.simple.MetricSettings;
import com.yahoo.metrics.simple.MetricReceiver;
import com.yahoo.processing.request.CompoundName;
-import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Coverage;
@@ -208,8 +207,7 @@ public class StatisticsSearcher extends Searcher {
* 2) Add response time to total response time (time from entry to return)
* 3) .....
*/
- @Override
- public Result search(Query query, Execution execution) {
+ public Result search(com.yahoo.search.Query query, Execution execution) {
if (query.properties().getBoolean(IGNORE_QUERY,false)) {
return execution.search(query);
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/Context.java b/container-search/src/main/java/com/yahoo/prelude/templates/Context.java
index 7989f35e77b..7a904ea014c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/Context.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/Context.java
@@ -9,10 +9,7 @@ import com.yahoo.text.XML;
* A set of variable bindings for template rendering
*
* @author bratseth
- * @deprecated use a Renderer instead
*/
-@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
public abstract class Context {
private boolean xmlEscape = true;
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java b/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java
index dab80580f61..f14d8ddf319 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/FormattingOptions.java
@@ -13,10 +13,7 @@ import java.util.Set;
* Defines formatting options used with special kinds of hits.
*
* @author laboisse
- * @deprecated use a Renderer instead
*/
-@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
public class FormattingOptions {
public static final String DEFAULT_TYPE_ATTRIBUTE_NAME = "type";
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java b/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java
index 4d1daa97306..037d1a77d5c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/HitContext.java
@@ -17,10 +17,7 @@ import java.util.Set;
* A context providing all the fields of a hit, and falls back to MapContext behavior for all other keys.
*
* @author tonytv
- * @deprecated use a Renderer instead
*/
-@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
public class HitContext extends Context {
private final Hit hit;
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java b/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java
index 84d97b71f60..49c5ffa6e78 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java
@@ -6,12 +6,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
-/**
- * A context having a map as secondary storage
- * @deprecated use a Renderer instead
- */
-@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
+/** A context having a map as secondary storage */
public class MapContext extends Context {
private Map<String, Object> map = new LinkedHashMap<>();
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java
index 83118ec66ad..a24fd623e4d 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/PageTemplateSet.java
@@ -14,10 +14,7 @@ import java.io.Writer;
* This is a variant of the tiled template set - see that class for details.
*
* @author bratseth
- * @deprecated use a Renderer instead
*/
-@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
public class PageTemplateSet extends TiledTemplateSet {
public PageTemplateSet() {
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java b/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java
index a639a6b97ec..31e133d22d5 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/SearchRendererAdaptor.java
@@ -21,10 +21,8 @@ import java.util.Iterator;
* Renders a search result using the old templates API.
*
* @author tonytv
- * @deprecated do not use
*/
@SuppressWarnings({ "rawtypes", "deprecation", "unchecked" })
-@Deprecated // TODO: Remove on Vespa 7
public final class SearchRendererAdaptor extends Renderer {
private final LogExceptionUserTemplateDelegator templates;
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/Template.java b/container-search/src/main/java/com/yahoo/prelude/templates/Template.java
index 3d00be9d05b..63bd3214b17 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/Template.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/Template.java
@@ -10,10 +10,7 @@ import java.io.Writer;
* template mechanism by subclassing this.
*
* @author bratseth
- * @deprecated use a Renderer instead
*/
-@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
public abstract class Template<T extends Writer> {
/**
@@ -22,7 +19,8 @@ public abstract class Template<T extends Writer> {
* @param context the context to evaluate in
* @param writer the writer to render to
*/
- public abstract void render(Context context,T writer) throws java.io.IOException;
+ public abstract void render(Context context,T writer)
+ throws java.io.IOException;
/**
diff --git a/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java b/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java
index 91bc33e3e2a..6bba0f620ee 100644
--- a/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java
+++ b/container-search/src/main/java/com/yahoo/prelude/templates/TiledTemplateSet.java
@@ -70,10 +70,7 @@ import java.util.stream.Collectors;
*
* @author bratseth
* @author laboisse
- * @deprecated use a Renderer instead
*/
-@SuppressWarnings("deprecation")
-@Deprecated // TODO: Remove on Vespa 7
public class TiledTemplateSet extends DefaultTemplateSet {
private FormattingOptions hitOptionsForProvider;
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 e9e4e34727c..1c6e92ebffc 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
@@ -230,7 +230,7 @@ public class SearchHandler extends LoggingRequestHandler {
return (e.getCause() instanceof IllegalArgumentException)
? invalidParameterResponse(request, e)
: illegalQueryResponse(request, e);
- } catch (RuntimeException e) { // Make sure we generate a valid response even on unexpected errors
+ } catch (RuntimeException e) { // Make sure we generate a valid XML response even on unexpected errors
log.log(Level.WARNING, "Failed handling " + request, e);
return internalServerErrorResponse(request, e);
}
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/NGramSearcher.java b/container-search/src/main/java/com/yahoo/search/querytransform/NGramSearcher.java
index 399ff6194c8..2768a546cd0 100644
--- a/container-search/src/main/java/com/yahoo/search/querytransform/NGramSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/querytransform/NGramSearcher.java
@@ -40,8 +40,8 @@ public class NGramSearcher extends Searcher {
private final CharacterClasses characterClasses;
public NGramSearcher(Linguistics linguistics) {
- gramSplitter = linguistics.getGramSplitter();
- characterClasses = linguistics.getCharacterClasses();
+ gramSplitter= linguistics.getGramSplitter();
+ characterClasses= linguistics.getCharacterClasses();
}
@Override
@@ -54,7 +54,7 @@ public class NGramSearcher extends Searcher {
if (rewritten)
query.trace("Rewritten to n-gram matching",true,2);
- Result result = execution.search(query);
+ Result result=execution.search(query);
recombineNGrams(result.hits().deepIterator(), session);
return result;
}
@@ -160,11 +160,10 @@ public class NGramSearcher extends Searcher {
if (hit.isMeta()) continue;
Object sddocname = hit.getField(Hit.SDDOCNAME_FIELD);
if (sddocname == null) return;
- for (Index index : session.getIndexes(sddocname.toString())) {
+ for (String fieldName : hit.fieldKeys()) { // TODO: Iterate over indexes instead
+ Index index = session.getIndex(fieldName, sddocname.toString());
if (index.isNGram() && (index.getHighlightSummary() || index.getDynamicSummary())) {
- Object fieldValue = hit.getField(index.getName());
- if (fieldValue != null)
- hit.setField(index.getName(), recombineNGramsField(fieldValue, index.getGramSize()));
+ hit.setField(fieldName, recombineNGramsField(hit.getField(fieldName), index.getGramSize()));
}
}
}
diff --git a/container-search/src/main/java/com/yahoo/search/result/Templating.java b/container-search/src/main/java/com/yahoo/search/result/Templating.java
index 9e191a1219c..47f40f3c7f5 100644
--- a/container-search/src/main/java/com/yahoo/search/result/Templating.java
+++ b/container-search/src/main/java/com/yahoo/search/result/Templating.java
@@ -15,10 +15,8 @@ import com.yahoo.search.query.Presentation;
* Helper methods and data store for result attributes geared towards result
* rendering and presentation.
*
- * @author Steinar Knutsen
- * @deprecated do not use
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
-@Deprecated // TODO: Remove on Vespa 7
public class Templating {
private final Result result;
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/model/VespaSearchers.java b/container-search/src/main/java/com/yahoo/search/searchchain/model/VespaSearchers.java
index 94fd9549939..fe3d48ccded 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/model/VespaSearchers.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/model/VespaSearchers.java
@@ -9,13 +9,10 @@ import com.yahoo.component.chain.model.ChainedComponentModel;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.model.federation.FederationSearcherModel;
import com.yahoo.search.searchchain.model.federation.FederationSearcherModel.TargetSpec;
+import org.apache.commons.collections.CollectionUtils;
+
+import java.util.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
/**
* Defines the searcher models used in the vespa and native search chains, except for federation.
@@ -26,6 +23,8 @@ import java.util.Set;
public class VespaSearchers {
public static final Collection<ChainedComponentModel> vespaSearcherModels =
toSearcherModels(
+ com.yahoo.prelude.querytransform.IndexCombinatorSearcher.class,
+ //com.yahoo.prelude.querytransform.LocalitySearcher.class,
com.yahoo.prelude.querytransform.PhrasingSearcher.class,
com.yahoo.prelude.searcher.FieldCollapsingSearcher.class,
com.yahoo.search.yql.MinimalQueryInserter.class,
@@ -60,8 +59,8 @@ public class VespaSearchers {
private static FederationSearcherModel federationSearcherModel() {
return new FederationSearcherModel(new ComponentSpecification("federation"),
- Dependencies.emptyDependencies(),
- Collections.<TargetSpec>emptyList(), true);
+ Dependencies.emptyDependencies(),
+ Collections.<TargetSpec>emptyList(), true);
}
private static boolean allAdded(Collection<ChainedComponentModel> searcherModels, Set<ComponentId> componentIds) {
@@ -83,4 +82,3 @@ public class VespaSearchers {
return searcherModels;
}
}
-
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java b/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java
index f4973ba4239..56a6a702962 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java
@@ -28,7 +28,7 @@ import com.yahoo.search.searchchain.Execution;
* Any field in the configured hits which has a name starting by attribute
* will be returned when attribute prefetch filling is requested.</p>
*
- * @author bratseth
+ * @author bratseth
*/
public class DocumentSourceSearcher extends Searcher {
@@ -85,6 +85,7 @@ public class DocumentSourceSearcher extends Searcher {
private void addDefaultResults() {
Query q = new Query("?query=default");
Result r = new Result(q);
+ // These four used to assign collapseId 1,2,3,4 - re-add that if needed
r.hits().add(new Hit("http://default-1.html", 0));
r.hits().add(new Hit("http://default-2.html", 0));
r.hits().add(new Hit("http://default-3.html", 0));
@@ -96,7 +97,8 @@ public class DocumentSourceSearcher extends Searcher {
@Override
public Result search(Query query, Execution execution) {
queryCount++;
- Result r = unFilledResults.get(getQueryKeyClone(query));
+ Result r;
+ r = unFilledResults.get(getQueryKeyClone(query));
if (r == null) {
r = defaultFilledResult.clone();
} else {
@@ -109,13 +111,12 @@ public class DocumentSourceSearcher extends Searcher {
}
/**
- * Returns a query clone which has sourcr, offset and hits set to null. This is used by access to
+ * Returns a query clone which has offset and hits set to null. This is used by access to
* the maps using the query as key to achieve lookup independent of offset/hits value
*/
private Query getQueryKeyClone(Query query) {
- Query key = query.clone();
+ Query key=query.clone();
key.setWindow(0,0);
- key.getModel().setSources("");
return key;
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
index 7761bca2773..4987f9902ce 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
@@ -17,15 +17,16 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.searcher.BlendingSearcher;
+import com.yahoo.prelude.searcher.DocumentSourceSearcher;
import com.yahoo.prelude.searcher.FillSearcher;
import com.yahoo.search.Searcher;
import com.yahoo.search.federation.FederationSearcher;
+import com.yahoo.search.federation.selection.TargetSelector;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChain;
import com.yahoo.search.searchchain.SearchChainRegistry;
-import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -39,6 +40,8 @@ import static org.junit.Assert.assertTrue;
* @author Bob Travis
* @author bratseth
*/
+// The SuppressWarnings is to shut up the compiler about using
+// deprecated FastHit constructor in the tests.
@SuppressWarnings({ "rawtypes" })
public class BlendingSearcherTestCase {
@@ -121,6 +124,7 @@ public class BlendingSearcherTestCase {
@Test
public void testitTwoPhase() {
+
DocumentSourceSearcher chain1 = new DocumentSourceSearcher();
DocumentSourceSearcher chain2 = new DocumentSourceSearcher();
DocumentSourceSearcher chain3 = new DocumentSourceSearcher();
@@ -135,19 +139,19 @@ public class BlendingSearcherTestCase {
r1.hits().add(new Hit("http://host1.com", 101){{setSource("one");}});
r1.hits().add(new Hit("http://host2.com", 102){{setSource("one");}});
r1.hits().add(new Hit("http://host3.com", 103){{setSource("one");}});
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.setTotalHitCount(17);
r2.hits().add(new Hit("http://host1.com", 101){{setSource("two");}});
r2.hits().add(new Hit("http://host2.com", 102){{setSource("two");}});
r2.hits().add(new Hit("http://host4.com", 104){{setSource("two");}});
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
r3.setTotalHitCount(37);
r3.hits().add(new Hit("http://host5.com", 100){{setSource("three");}});
r3.hits().add(new Hit("http://host6.com", 106){{setSource("three");}});
r3.hits().add(new Hit("http://host7.com", 105){{setSource("three");}});
- chain3.addResult(q, r3);
+ chain3.addResultSet(q, r3);
BlendingSearcherWrapper blender1 = new BlendingSearcherWrapper();
blender1.addChained(chain1, "one");
@@ -211,10 +215,10 @@ public class BlendingSearcherTestCase {
r1.setTotalHitCount(1);
r1.hits().add(new FastHit("http://host1.com/", 101));
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.hits().add(new FastHit("http://host1.com/", 102));
r2.setTotalHitCount(1);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper("uri");
blender.addChained(new FillSearcher(chain1), "a");
@@ -235,10 +239,10 @@ public class BlendingSearcherTestCase {
Result r2 = new Result(q, ErrorMessage.createRequestTooLarge(null));
r1.setTotalHitCount(0);
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.hits().add(new FastHit("http://host1.com/", 102));
r2.setTotalHitCount(1);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(chain1), "a");
@@ -284,7 +288,7 @@ public class BlendingSearcherTestCase {
r1.hits().add(r1h1);
r1.hits().add(r1h2);
r1.hits().add(r1h3);
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.setTotalHitCount(3);
Hit r2h1 = new Hit("http://host1.com/relevancy201", 201);
@@ -299,7 +303,7 @@ public class BlendingSearcherTestCase {
r2.hits().add(r2h1);
r2.hits().add(r2h2);
r2.hits().add(r2h3);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(chain1), "chainedone");
@@ -339,7 +343,7 @@ public class BlendingSearcherTestCase {
r1.hits().add(r1h1);
r1.hits().add(r1h2);
r1.hits().add(r1h3);
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.setTotalHitCount(3);
Hit r2h1 = new Hit("http://host1.com/relevancy201", 201);
@@ -351,7 +355,7 @@ public class BlendingSearcherTestCase {
r2.hits().add(r2h1);
r2.hits().add(r2h2);
r2.hits().add(r2h3);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(chain1, "chainedone");
@@ -377,7 +381,7 @@ public class BlendingSearcherTestCase {
r1.setTotalHitCount(1);
Hit r1h1 = new Hit("http://first/relevancy100", 200);
r1.hits().add(r1h1);
- first.addResult(query, r1);
+ first.addResultSet(query, r1);
Result r2 = new Result(query);
r2.setTotalHitCount(2);
@@ -385,7 +389,7 @@ public class BlendingSearcherTestCase {
Hit r2h2 = new Hit("http://second/relevancy100", 100);
r2.hits().add(r2h1);
r2.hits().add(r2h2);
- second.addResult(query, r2);
+ second.addResultSet(query, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(first), "first");
@@ -475,12 +479,13 @@ public class BlendingSearcherTestCase {
Query query = new Query("/search?query=banana&search=first,nonesuch,second");
Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
- assertEquals(4, result.getHitCount());
+ assertEquals(3, result.getConcreteHitCount());
assertEquals(300.0, result.hits().get(1).getRelevance().getScore(), delta);
assertEquals(200.0, result.hits().get(2).getRelevance().getScore(), delta);
assertEquals(100.0, result.hits().get(3).getRelevance().getScore(), delta);
assertNotNull(result.hits().getError());
ErrorMessage e = result.hits().getError();
+ //TODO: Do not depend on sources order
assertEquals("Could not resolve source ref 'nonesuch'. Valid source refs are first, second.",
e.getDetailedMessage());
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
index 9f4a12d24e6..f71c0803ce8 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
@@ -28,9 +28,9 @@ import java.util.List;
import java.util.Map;
/**
- * Tests juniper highlighting
+ * Tests conversion of juniper highlighting to XML
*
- * @author Steinar Knutsen
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
public class JuniperSearcherTestCase {
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
index 691f877dfba..ee735104caa 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
@@ -15,9 +15,9 @@ import com.yahoo.search.Result;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.hitfield.HitField;
import com.yahoo.search.Searcher;
+import com.yahoo.prelude.searcher.DocumentSourceSearcher;
import com.yahoo.prelude.searcher.QuotingSearcher;
import com.yahoo.search.searchchain.Execution;
-import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
import org.junit.Test;
import java.util.ArrayList;
@@ -55,7 +55,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", "smith & jones");
r.hits().add(hit);
- docsource.addResult(q, r);
+ docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("smith &amp; jones", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
@@ -75,7 +75,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", "&smith &jo& nes");
r.hits().add(hit);
- docsource.addResult(q, r);
+ docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("&amp;smith &amp;jo&amp; nes", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
@@ -95,7 +95,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", new HitField("title", "&smith &jo& nes"));
r.hits().add(hit);
- docsource.addResult(q, r);
+ docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("&amp;smith &amp;jo&amp; nes", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
@@ -116,7 +116,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", Integer.valueOf(42));
r.hits().add(hit);
- docsource.addResult(q, r);
+ docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
// should not quote non-string properties
assertEquals(Integer.valueOf(42), check.hits().get(0).getField("title"));
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
index a3f7ff12319..99b7eeff9a0 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
@@ -46,32 +46,32 @@ public class NGramSearcherTestCase {
@Before
public void setUp() {
- searcher = new NGramSearcher(new SimpleLinguistics());
- indexFacts = new IndexFacts();
+ searcher=new NGramSearcher(new SimpleLinguistics());
+ indexFacts=new IndexFacts();
- Index defaultIndex = new Index("default");
- defaultIndex.setNGram(true, 3);
+ Index defaultIndex=new Index("default");
+ defaultIndex.setNGram(true,3);
defaultIndex.setDynamicSummary(true);
- indexFacts.addIndex("default", defaultIndex);
+ indexFacts.addIndex("default",defaultIndex);
- Index test = new Index("test");
+ Index test=new Index("test");
test.setHighlightSummary(true);
- indexFacts.addIndex("default", test);
+ indexFacts.addIndex("default",test);
- Index gram2 = new Index("gram2");
- gram2.setNGram(true, 2);
+ Index gram2=new Index("gram2");
+ gram2.setNGram(true,2);
gram2.setDynamicSummary(true);
- indexFacts.addIndex("default", gram2);
+ indexFacts.addIndex("default",gram2);
- Index gram3 = new Index("gram3");
- gram3.setNGram(true, 3);
+ Index gram3=new Index("gram3");
+ gram3.setNGram(true,3);
gram3.setHighlightSummary(true);
- indexFacts.addIndex("default", gram3);
+ indexFacts.addIndex("default",gram3);
- Index gram14 = new Index("gram14");
- gram14.setNGram(true, 14);
+ Index gram14=new Index("gram14");
+ gram14.setNGram(true,14);
gram14.setDynamicSummary(true);
- indexFacts.addIndex("default", gram14);
+ indexFacts.addIndex("default",gram14);
}
private IndexFacts getMixedSetup() {
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java
index 4390f70cac0..7a59be49458 100755
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java
@@ -7,6 +7,7 @@ import com.yahoo.document.Field;
import com.yahoo.document.datatypes.FieldValue;
import com.yahoo.document.datatypes.Raw;
import com.yahoo.io.ByteWriter;
+import com.yahoo.prelude.templates.Context;
import com.yahoo.text.XML;
import java.io.IOException;
@@ -37,7 +38,7 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void error(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void error(Context context, Writer writer) throws IOException {
// Error shouldn't be handled by this template, but rather
// delegated to the searcher
}
@@ -54,7 +55,7 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void header(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void header(Context context, Writer writer) throws IOException {
if (wrapXml) {
// XML wrapping should only be used for default field rendering
writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
@@ -63,14 +64,14 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void footer(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void footer(Context context, Writer writer) throws IOException {
if (wrapXml) {
writer.write("</result>\n");
}
}
@Override
- public void hit(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void hit(Context context, Writer writer) throws IOException {
DocumentHit hit = (DocumentHit)context.get("hit");
Document doc = hit.getDocument();
// Assume field existence has been checked before we ever get here.
@@ -87,11 +88,11 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void hitFooter(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void hitFooter(Context context, Writer writer) throws IOException {
}
@Override
- public void noHits(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void noHits(Context context, Writer writer) throws IOException {
}
}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java
index b16f39800ef..25ee0ff5d03 100755
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java
@@ -6,6 +6,7 @@ import com.yahoo.search.Result;
import com.yahoo.search.result.ErrorHit;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.HitGroup;
+import com.yahoo.prelude.templates.Context;
import com.yahoo.search.result.Hit;
import com.yahoo.text.XML;
@@ -54,7 +55,7 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void error(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void error(Context context, Writer writer) throws IOException {
writer.write("<errors>\n");
// If the error contains no error hits, use a single error with the main
// code and description. Otherwise, use the error hits explicitly
@@ -71,7 +72,7 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void header(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void header(Context context, Writer writer) throws IOException {
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
writer.write("<result>\n");
HitGroup rootGroup = ((Result) context.get("result")).hits();
@@ -81,12 +82,12 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void footer(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void footer(Context context, Writer writer) throws IOException {
writer.write("</result>\n");
}
@Override
- public void hit(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void hit(Context context, Writer writer) throws IOException {
Hit hit = (Hit)context.get("hit");
if (hit instanceof DocumentHit) {
DocumentHit docHit = (DocumentHit) hit;
@@ -109,11 +110,11 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void hitFooter(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void hitFooter(Context context, Writer writer) throws IOException {
}
@Override
- public void noHits(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
+ public void noHits(Context context, Writer writer) throws IOException {
}
}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
index 835a11bf7c2..5f1c96d000f 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
@@ -183,9 +183,9 @@ class ClientFeederV3 {
if (! operationId.isPresent()) {
return Optional.empty();
}
- final DocumentOperationMessageV3 message;
+ final DocumentOperationMessageV3 msg;
try {
- message = getNextMessage(operationId.get(), requestInputStream, settings);
+ msg = getNextMessage(operationId.get(), requestInputStream, settings);
} catch (Exception e) {
if (log.isLoggable(LogLevel.DEBUG)) {
log.log(LogLevel.DEBUG, Exceptions.toMessageString(e), e);
@@ -195,9 +195,8 @@ class ClientFeederV3 {
continue;
}
- if (message != null)
- setRoute(message, settings);
- return Optional.ofNullable(message);
+ setRoute(msg, settings);
+ return Optional.of(msg);
}
}
@@ -274,7 +273,6 @@ class ClientFeederV3 {
}
// protected for mocking
- /** Returns the next message in the stream, or null if none */
protected DocumentOperationMessageV3 getNextMessage(
String operationId, InputStream requestInputStream, FeederSettings settings) throws Exception {
VespaXMLFeedReader.Operation operation = streamReaderV3.getNextOperation(requestInputStream, settings);
@@ -287,14 +285,14 @@ class ClientFeederV3 {
null);
}
- DocumentOperationMessageV3 message = DocumentOperationMessageV3.create(operation, operationId, metric);
- if (message == null) {
+ DocumentOperationMessageV3 msg = DocumentOperationMessageV3.create(operation, operationId, metric);
+ if (msg == null) {
// typical end of feed
return null;
}
metric.add(MetricNames.NUM_OPERATIONS, 1, null /*metricContext*/);
- log(LogLevel.DEBUG, "Successfully deserialized document id: ", message.getOperationId());
- return message;
+ log(LogLevel.DEBUG, "Successfully deserialized document id: ", msg.getOperationId());
+ return msg;
}
private void setMessageParameters(DocumentOperationMessageV3 msg, FeederSettings settings) {
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java
index 9d6c8c2feac..2424ce596a3 100755
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java
+++ b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java
@@ -17,9 +17,11 @@ import com.yahoo.feedapi.FeedContext;
import com.yahoo.feedapi.MessagePropertyProcessor;
import com.yahoo.messagebus.Message;
import com.yahoo.messagebus.routing.Route;
+import com.yahoo.prelude.templates.SearchRendererAdaptor;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
+import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
@@ -738,7 +740,7 @@ public class GetSearcherTestCase {
assertEquals("application/octet-stream", result.getTemplating().getTemplates().getMimeType());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- com.yahoo.prelude.templates.SearchRendererAdaptor.callRender(stream, result);
+ SearchRendererAdaptor.callRender(stream, result);
stream.flush();
byte[] resultBytes = stream.toByteArray();
@@ -767,7 +769,7 @@ public class GetSearcherTestCase {
assertEquals("text/fancy", result.getTemplating().getTemplates().getMimeType());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- com.yahoo.prelude.templates.SearchRendererAdaptor.callRender(stream, result);
+ SearchRendererAdaptor.callRender(stream, result);
stream.flush();
byte[] resultBytes = stream.toByteArray();