diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-12-03 10:16:37 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-12-03 10:16:37 +0100 |
commit | 868a770f58ff5616489886091d944a04e698dda5 (patch) | |
tree | 746404439f4df0d583fbe03e7429a99c42c705cd /container-search | |
parent | 797b8ad6223492bcf0106b0a4001a7478526ed09 (diff) |
Simplify
Diffstat (limited to 'container-search')
3 files changed, 4 insertions, 11 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 aa3d6a2c0f8..7b403ca3659 100644 --- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java +++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java @@ -333,10 +333,8 @@ public class IndexFacts { /** * Returns the index for this name. * - * @param indexName the name of the index. If this is null or empty the index - * named "default" is returned - * @return the index best matching the input parameters or the nullIndex - * (never null) if none is found + * @param indexName the name of the index. If this is null or empty the index named "default" is returned + * @return the index best matching the input parameters or the null Index (never null) if none is found */ public Index getIndex(String indexName) { return IndexFacts.this.getIndexFromDocumentTypes(indexName, documentTypes); diff --git a/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java b/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java index 26b5c2bc665..024f231f524 100644 --- a/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java +++ b/container-search/src/main/java/com/yahoo/search/searchers/QueryValidator.java @@ -45,8 +45,7 @@ public class QueryValidator extends Searcher { public boolean visit(Item item) { if (item instanceof HasIndexItem) { String indexName = ((HasIndexItem)item).getIndexName(); - Index index = session.getIndex(indexName); - if (index != null && index.isTensor()) + if (session.getIndex(indexName).isTensor()) throw new IllegalArgumentException("Cannot search '" + indexName + "': It is a tensor field"); } return true; diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java index 62089f48317..8789de7198c 100644 --- a/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java @@ -1,19 +1,15 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.searchers.test; -import com.yahoo.config.subscription.ConfigGetter; import com.yahoo.prelude.IndexFacts; import com.yahoo.prelude.IndexModel; import com.yahoo.prelude.SearchDefinition; import com.yahoo.search.Query; -import com.yahoo.search.config.IndexInfoConfig; import com.yahoo.search.searchchain.Execution; import com.yahoo.search.searchers.QueryValidator; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** @@ -33,7 +29,7 @@ public class QueryValidatorTestCase { new QueryValidator().search(new Query("?query=mystring:foo"), execution); try { - new QueryValidator().search(new Query("?query=mytensor:foo"), execution); + new QueryValidator().search(new Query("?query=sddocname%3Aproduct%20lfmModel25KeysV0%3A9%2A%20mytensor%3A%3E0"), execution); fail("Excpected validation error"); } catch (IllegalArgumentException e) { |