diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-08-06 09:00:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 09:00:49 +0200 |
commit | 69d381253a651dce0c6808240dc78e9a62c04f39 (patch) | |
tree | 0180a63b681770183891c161cfbd438758dac63a | |
parent | 35283b454dfdaa9acbcea24274e01e65d128b7b6 (diff) | |
parent | 9872031d2880d0ed5418d487cd8be848af83beaa (diff) |
Merge pull request #10191 from vespa-engine/bratseth/index-validation-correction
Bratseth/index validation correction
4 files changed, 33 insertions, 31 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java index 3f3fc11380b..942b6a449f3 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java @@ -2,8 +2,9 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.document.CollectionDataType; +import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.document.*; import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; @@ -36,12 +37,12 @@ public class NGramMatch extends Processor { } private void implementGramMatch(Search search, SDField field, boolean validate) { - if (validate && field.doesAttributing()) - throw new IllegalArgumentException("gram matching is not supported with attributes, use 'index' not 'attribute' in indexing"); + if (validate && field.doesAttributing() && ! field.doesIndexing()) + throw new IllegalArgumentException("gram matching is not supported with attributes, use 'index' in indexing"); int n = field.getMatching().getGramSize(); if (n < 0) - n=DEFAULT_GRAM_SIZE; // not set - use default gram size + n = DEFAULT_GRAM_SIZE; // not set - use default gram size if (validate && n == 0) throw new IllegalArgumentException("Illegal gram size in " + field + ": Must be at least 1"); field.getNormalizing().inferCodepoint(); @@ -67,9 +68,8 @@ public class NGramMatch extends Processor { @Override protected Expression newTransform(DataType fieldType) { Expression exp = new NGramExpression(null, ngram); - if (fieldType instanceof CollectionDataType) { + if (fieldType instanceof CollectionDataType) exp = new ForEachExpression(exp); - } return exp; } diff --git a/config-model/src/test/examples/ngram.sd b/config-model/src/test/examples/ngram.sd index 6324dd0fbd1..5d70d8dc536 100644 --- a/config-model/src/test/examples/ngram.sd +++ b/config-model/src/test/examples/ngram.sd @@ -13,9 +13,8 @@ search ngram { } field gram_2 type string { - indexing: index + indexing: attribute | index # index take precedence for matching match: gram # gram-size 2 is default - # index-to: gram_2, default } field gram_3 type string { @@ -24,7 +23,6 @@ search ngram { gram gram-size: 3 } - # index-to: gram_3, default } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java index 0219d86e182..385d1df90ad 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java @@ -13,7 +13,11 @@ import org.junit.Test; import java.io.IOException; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + /** * @author bratseth */ @@ -24,28 +28,28 @@ public class NGramTestCase extends SearchDefinitionTestCase { Search search = SearchBuilder.buildFromFile("src/test/examples/ngram.sd"); assertNotNull(search); - SDField gram1=search.getConcreteField("gram_1"); - assertEquals(Matching.Type.GRAM,gram1.getMatching().getType()); - assertEquals(1,gram1.getMatching().getGramSize()); + SDField gram1 = search.getConcreteField("gram_1"); + assertEquals(Matching.Type.GRAM, gram1.getMatching().getType()); + assertEquals(1, gram1.getMatching().getGramSize()); - SDField gram2=search.getConcreteField("gram_2"); - assertEquals(Matching.Type.GRAM,gram2.getMatching().getType()); - assertEquals(-1,gram2.getMatching().getGramSize()); // Not set explicitly + SDField gram2 = search.getConcreteField("gram_2"); + assertEquals(Matching.Type.GRAM, gram2.getMatching().getType()); + assertEquals(-1, gram2.getMatching().getGramSize()); // Not set explicitly SDField gram3=search.getConcreteField("gram_3"); assertEquals(Matching.Type.GRAM,gram3.getMatching().getType()); - assertEquals(3,gram3.getMatching().getGramSize()); + assertEquals(3, gram3.getMatching().getGramSize()); - assertEquals("input gram_1 | ngram 1 | index gram_1 | summary gram_1",gram1.getIndexingScript().iterator().next().toString()); - assertEquals("input gram_2 | ngram 2 | index gram_2",gram2.getIndexingScript().iterator().next().toString()); - assertEquals("input gram_3 | ngram 3 | index gram_3",gram3.getIndexingScript().iterator().next().toString()); + assertEquals("input gram_1 | ngram 1 | index gram_1 | summary gram_1", gram1.getIndexingScript().iterator().next().toString()); + assertEquals("input gram_2 | ngram 2 | attribute gram_2 | index gram_2", gram2.getIndexingScript().iterator().next().toString()); + assertEquals("input gram_3 | ngram 3 | index gram_3", gram3.getIndexingScript().iterator().next().toString()); assertFalse(gram1.getNormalizing().doRemoveAccents()); - assertEquals(Stemming.NONE,gram1.getStemming()); + assertEquals(Stemming.NONE, gram1.getStemming()); - List<String> queryCommands=gram1.getQueryCommands(); - assertEquals(1,queryCommands.size()); - assertEquals("ngram 1",queryCommands.get(0)); + List<String> queryCommands = gram1.getQueryCommands(); + assertEquals(1, queryCommands.size()); + assertEquals("ngram 1", queryCommands.get(0)); } @Test @@ -55,7 +59,7 @@ public class NGramTestCase extends SearchDefinitionTestCase { fail("Should cause an exception"); } catch (IllegalArgumentException e) { - assertEquals("gram-size can only be set when the matching mode is 'gram'",e.getMessage()); + assertEquals("gram-size can only be set when the matching mode is 'gram'", e.getMessage()); } } @@ -66,7 +70,7 @@ public class NGramTestCase extends SearchDefinitionTestCase { fail("Should cause an exception"); } catch (IllegalArgumentException e) { - assertEquals("gram-size can only be set when the matching mode is 'gram'",e.getMessage()); + assertEquals("gram-size can only be set when the matching mode is 'gram'", e.getMessage()); } } @@ -77,7 +81,7 @@ public class NGramTestCase extends SearchDefinitionTestCase { fail("Should cause an exception"); } catch (IllegalArgumentException e) { - assertEquals("gram matching is not supported with attributes, use 'index' not 'attribute' in indexing",e.getMessage()); + assertEquals("gram matching is not supported with attributes, use 'index' in indexing", e.getMessage()); } } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java index a7b750c4e46..ae43a96f9fd 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java @@ -290,7 +290,7 @@ public class NodeFailer extends Maintainer { /** * We can attempt to fail any number of *tenant* and *host* nodes because the operation will not be effected * unless the node is replaced. - * We can also attempt to fail a single proxy(host) as there should be enough redudancy to handle that. + * We can also attempt to fail a single proxy(host) as there should be enough redundancy to handle that. * But we refuse to fail out config(host)/controller(host) */ private boolean failAllowedFor(NodeType nodeType) { @@ -307,15 +307,15 @@ public class NodeFailer extends Maintainer { } /** - * Returns true if the node is considered bad: all monitored services services are down. - * If a node remains bad for a long time, the NodeFailer will eventually try to fail the node. + * Returns true if the node is considered bad: All monitored services services are down. + * If a node remains bad for a long time, the NodeFailer will try to fail the node. */ static boolean badNode(List<ServiceInstance> services) { Map<ServiceStatus, Long> countsByStatus = services.stream() .collect(Collectors.groupingBy(ServiceInstance::serviceStatus, counting())); return countsByStatus.getOrDefault(ServiceStatus.UP, 0L) <= 0L && - countsByStatus.getOrDefault(ServiceStatus.DOWN, 0L) > 0L; + countsByStatus.getOrDefault(ServiceStatus.DOWN, 0L) > 0L; } /** |