diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-10-15 20:16:48 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-10-15 20:16:48 +0200 |
commit | 8b0181f5bfd7755fd3b96f26428861bee78190b8 (patch) | |
tree | 25414c023f22ca6e644dd3b664634f093458465c /container-search | |
parent | b28a953489d50d4366ebd01922ea1d1febdfe86c (diff) |
Avoid deprecated method
Diffstat (limited to 'container-search')
5 files changed, 32 insertions, 16 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 640282439d5..448d8e7855f 100644 --- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java +++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java @@ -108,7 +108,11 @@ public class IndexFacts { /** * Public only for testing. + * + * @deprecated set at creation time */ + // TODO: Remove on Vespa 7 + @Deprecated // OK public void setClusters(Map<String, List<String>> clusters) { ensureNotFrozen(); this.clusters = clusters; @@ -343,7 +347,7 @@ public class IndexFacts { * @deprecated set indexes at creation time instead */ // TODO: Remove on Vespa 7 - @Deprecated + @Deprecated // OK public void addIndex(String sdName, Index index) { ensureNotFrozen(); diff --git a/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java index bb73e1f4217..b9b29f5fc2b 100644 --- a/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/federation/test/DuplicateSourceTestCase.java @@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList; import com.yahoo.component.ComponentId; import com.yahoo.component.chain.Chain; import com.yahoo.prelude.IndexFacts; +import com.yahoo.prelude.IndexModel; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; @@ -14,6 +15,7 @@ import com.yahoo.search.searchchain.Execution; import com.yahoo.search.searchchain.SearchChainRegistry; import org.junit.Test; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,10 +38,9 @@ public class DuplicateSourceTestCase { MockBackendSearcher mockBackendSearcher = new MockBackendSearcher(); SearchChainRegistry searchChains = new SearchChainRegistry(); searchChains.register(new Chain<>("chain1", mockBackendSearcher)); - IndexFacts indexFacts = new IndexFacts(); Map<String, List<String>> clusters = new HashMap<>(); clusters.put("chain1", ImmutableList.of("doc1", "doc2")); - indexFacts.setClusters(clusters); + IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, Collections.emptyList())); SearchChainResolver resolver = new SearchChainResolver.Builder() .addSearchChain(new ComponentId("chain1"), ImmutableList.of("doc1", "doc2")) .build(); diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java index 00bd87b4bf9..cb380b31030 100644 --- a/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java @@ -6,6 +6,8 @@ import com.yahoo.language.Linguistics; import com.yahoo.language.simple.SimpleLinguistics; import com.yahoo.prelude.Index; import com.yahoo.prelude.IndexFacts; +import com.yahoo.prelude.IndexModel; +import com.yahoo.prelude.SearchDefinition; import com.yahoo.prelude.query.AndItem; import com.yahoo.prelude.query.IntItem; import com.yahoo.prelude.query.Item; @@ -19,6 +21,7 @@ import com.yahoo.search.querytransform.RangeQueryOptimizer; import com.yahoo.search.searchchain.Execution; import org.junit.Test; +import java.util.Collections; import java.util.Iterator; import static org.junit.Assert.*; @@ -210,15 +213,15 @@ public class RangeQueryOptimizerTestCase { } private static IndexFacts createIndexFacts() { - IndexFacts indexFacts = new IndexFacts(); + SearchDefinition sd = new SearchDefinition("test"); Index singleValue1 = new Index("s"); Index singleValue2 = new Index("t"); Index multiValue = new Index("m"); multiValue.setMultivalue(true); - indexFacts.addIndex("test", singleValue1); - indexFacts.addIndex("test", singleValue2); - indexFacts.addIndex("test", multiValue); - return indexFacts; + sd.addIndex(singleValue1); + sd.addIndex(singleValue2); + sd.addIndex(multiValue); + return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd))); } } diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java index 5b0c2c7e5a3..243bacc73b3 100644 --- a/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java @@ -4,6 +4,8 @@ package com.yahoo.search.querytransform.test; import com.yahoo.component.chain.Chain; import com.yahoo.prelude.Index; import com.yahoo.prelude.IndexFacts; +import com.yahoo.prelude.IndexModel; +import com.yahoo.prelude.SearchDefinition; import com.yahoo.prelude.query.QueryException; import com.yahoo.search.Query; import com.yahoo.search.Result; @@ -14,6 +16,8 @@ import com.yahoo.search.querytransform.SortingDegrader; import com.yahoo.search.searchchain.Execution; import org.junit.Test; +import java.util.Collections; + import static org.junit.Assert.*; /** @@ -147,7 +151,7 @@ public class SortingDegraderTestCase { } private IndexFacts createIndexFacts() { - IndexFacts indexFacts = new IndexFacts(); + SearchDefinition test = new SearchDefinition("test"); Index fastSearchAttribute1 = new Index("a1"); fastSearchAttribute1.setFastSearch(true); @@ -163,11 +167,11 @@ public class SortingDegraderTestCase { Index stringAttribute = new Index("stringAttribute"); stringAttribute.setFastSearch(true); - indexFacts.addIndex("test", fastSearchAttribute1); - indexFacts.addIndex("test", fastSearchAttribute2); - indexFacts.addIndex("test", nonFastSearchAttribute); - indexFacts.addIndex("stringAttribute", stringAttribute); - return indexFacts; + test.addIndex(fastSearchAttribute1); + test.addIndex(fastSearchAttribute2); + test.addIndex(nonFastSearchAttribute); + test.addIndex(stringAttribute); + return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(test))); } } diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java index 931ee99fdaa..2b0398a8e45 100644 --- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java @@ -13,6 +13,8 @@ import com.yahoo.language.simple.SimpleDetector; import com.yahoo.language.simple.SimpleLinguistics; import com.yahoo.prelude.Index; import com.yahoo.prelude.IndexFacts; +import com.yahoo.prelude.IndexModel; +import com.yahoo.prelude.SearchDefinition; import com.yahoo.prelude.query.AndItem; import com.yahoo.prelude.query.CompositeItem; import com.yahoo.prelude.query.Highlight; @@ -40,6 +42,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -769,14 +772,15 @@ public class QueryTestCase { private void assertDetectionText(String expectedDetectionText, String queryString, String ... indexSpecs) { Query q = new Query(httpEncode("/?query=" + queryString)); - IndexFacts indexFacts = new IndexFacts(); + SearchDefinition sd = new SearchDefinition("testSearchDefinition"); for (String indexSpec : indexSpecs) { String[] specParts = indexSpec.split(":"); Index tokenIndex = new Index(specParts[1]); if (specParts[0].equals("text")) tokenIndex.setPlainTokens(true); - indexFacts.addIndex("testSearchDefinition", tokenIndex); + sd.addIndex(tokenIndex); } + IndexFacts indexFacts = new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd))); MockLinguistics mockLinguistics = new MockLinguistics(); q.getModel().setExecution(new Execution(Execution.Context.createContextStub(null, indexFacts, mockLinguistics))); q.getModel().getQueryTree(); // cause parsing |