summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2021-04-07 08:36:29 +0200
committerGitHub <noreply@github.com>2021-04-07 08:36:29 +0200
commit64bb297066f7dc0d328836bd2f3f8b5e0622f53a (patch)
tree03c8a77430f26640c7d539d01613737e6f8b4d72
parent01dc174dd09fbdb0c04fd4fc28cdb3918185203e (diff)
parent3a89d04fbc987b4a658f5e200d02987f51f9131e (diff)
Merge pull request #17291 from vespa-engine/bratseth/lowercase-test
Bratseth/lowercase test
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java6
-rw-r--r--config-model/src/test/derived/lowercase/ilscripts.cfg9
-rw-r--r--config-model/src/test/derived/lowercase/index-info.cfg41
-rw-r--r--config-model/src/test/derived/lowercase/lowercase.sd21
-rw-r--r--config-model/src/test/examples/indexrewrite.sd6
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/derived/LowercaseTestCase.java19
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java5
7 files changed, 100 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java
index 72777b7dfb4..7bc12dec331 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java
@@ -51,9 +51,9 @@ public class IndexingValues extends Processor {
protected boolean shouldConvert(Expression exp) {
if (exp instanceof OutputExpression && mutatedBy != null) {
throw newProcessException(search, field,
- "Indexing expression '" + mutatedBy + "' modifies the value of the " +
- "document field '" + field.getName() + "'. This is no longer supported -- " +
- "declare such fields outside the document.");
+ "Indexing expression '" + mutatedBy + "' attempts to modify the value of the " +
+ "document field '" + field.getName() + "'. Use a field outside the document " +
+ "block instead.");
}
if (exp instanceof InputExpression && ((InputExpression)exp).getFieldName().equals(field.getName())) {
mutatedBy = null;
diff --git a/config-model/src/test/derived/lowercase/ilscripts.cfg b/config-model/src/test/derived/lowercase/ilscripts.cfg
new file mode 100644
index 00000000000..0cf56eb43e0
--- /dev/null
+++ b/config-model/src/test/derived/lowercase/ilscripts.cfg
@@ -0,0 +1,9 @@
+maxtermoccurrences 100
+fieldmatchmaxlength 1000000
+ilscript[].doctype "lowercase"
+ilscript[].docfield[] "single_field_source"
+ilscript[].docfield[] "array_field_source"
+ilscript[].content[] "clear_state | guard { input array_field_source | for_each { lowercase } | for_each { tokenize normalize stem:\"BEST\" } | summary array_field | index array_field; }"
+ilscript[].content[] "clear_state | guard { input single_field_source | lowercase | tokenize normalize stem:\"BEST\" | summary single_field | index single_field; }"
+ilscript[].content[] "input array_field_source | passthrough array_field_source"
+ilscript[].content[] "input single_field_source | passthrough single_field_source" \ No newline at end of file
diff --git a/config-model/src/test/derived/lowercase/index-info.cfg b/config-model/src/test/derived/lowercase/index-info.cfg
new file mode 100644
index 00000000000..b94125de79d
--- /dev/null
+++ b/config-model/src/test/derived/lowercase/index-info.cfg
@@ -0,0 +1,41 @@
+indexinfo[].name "lowercase"
+indexinfo[].command[].indexname "sddocname"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "sddocname"
+indexinfo[].command[].command "word"
+indexinfo[].command[].indexname "single_field_source"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "single_field_source"
+indexinfo[].command[].command "type string"
+indexinfo[].command[].indexname "array_field_source"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "array_field_source"
+indexinfo[].command[].command "multivalue"
+indexinfo[].command[].indexname "array_field_source"
+indexinfo[].command[].command "type Array<string>"
+indexinfo[].command[].indexname "array_field"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "array_field"
+indexinfo[].command[].command "lowercase"
+indexinfo[].command[].indexname "array_field"
+indexinfo[].command[].command "multivalue"
+indexinfo[].command[].indexname "array_field"
+indexinfo[].command[].command "stem:BEST"
+indexinfo[].command[].indexname "array_field"
+indexinfo[].command[].command "normalize"
+indexinfo[].command[].indexname "array_field"
+indexinfo[].command[].command "plain-tokens"
+indexinfo[].command[].indexname "array_field"
+indexinfo[].command[].command "type Array<string>"
+indexinfo[].command[].indexname "single_field"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "single_field"
+indexinfo[].command[].command "lowercase"
+indexinfo[].command[].indexname "single_field"
+indexinfo[].command[].command "stem:BEST"
+indexinfo[].command[].indexname "single_field"
+indexinfo[].command[].command "normalize"
+indexinfo[].command[].indexname "single_field"
+indexinfo[].command[].command "plain-tokens"
+indexinfo[].command[].indexname "single_field"
+indexinfo[].command[].command "type string" \ No newline at end of file
diff --git a/config-model/src/test/derived/lowercase/lowercase.sd b/config-model/src/test/derived/lowercase/lowercase.sd
new file mode 100644
index 00000000000..de8c7ad729e
--- /dev/null
+++ b/config-model/src/test/derived/lowercase/lowercase.sd
@@ -0,0 +1,21 @@
+schema lowercase {
+
+ document lowercase {
+
+ field single_field_source type string {
+ }
+
+ field array_field_source type array<string> {
+ }
+
+ }
+
+ field single_field type string {
+ indexing: input single_field_source | lowercase | summary | index
+ }
+
+ field array_field type array<string> {
+ indexing: input array_field_source | for_each { lowercase } | summary | index
+ }
+
+} \ No newline at end of file
diff --git a/config-model/src/test/examples/indexrewrite.sd b/config-model/src/test/examples/indexrewrite.sd
index c7d038a719a..c9fa7a1530a 100644
--- a/config-model/src/test/examples/indexrewrite.sd
+++ b/config-model/src/test/examples/indexrewrite.sd
@@ -1,19 +1,21 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
search indexrewrite {
+
document indexrewrite {
field title_src type string {
-
}
}
+
field title type string {
indexing: input title_src | lowercase | normalize | tokenize | index
- # index-to: title, titleabstract, default
indexing-rewrite: none
rank-type: about
stemming: none
alias: headline
}
+
field title_s type string {
indexing: input title_src | summary
}
+
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/LowercaseTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LowercaseTestCase.java
new file mode 100644
index 00000000000..253bb2f4f00
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LowercaseTestCase.java
@@ -0,0 +1,19 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.searchdefinition.derived;
+
+import com.yahoo.searchdefinition.parser.ParseException;
+import org.junit.Test;
+
+import java.io.IOException;
+
+/**
+ * @author bratseth
+ */
+public class LowercaseTestCase extends AbstractExportingTestCase {
+
+ @Test
+ public void testDeriving() throws IOException, ParseException {
+ assertCorrectDeriving("lowercase");
+ }
+
+}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java
index a1c454da822..823ad556b1d 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java
@@ -23,7 +23,8 @@ public class IndexingValuesTestCase {
public void requireThatInputOtherFieldThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_input_other_field.sd",
"For search 'indexing_input_other_field', field 'bar': Indexing expression 'input foo' " +
- "modifies the value of the document field 'bar'. This is no longer supported -- declare " +
- "such fields outside the document.");
+ "attempts to modify the value of the document field 'bar'. " +
+ "Use a field outside the document block instead.");
}
+
}