aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-12-07 16:08:56 +0100
committerTor Egge <Tor.Egge@online.no>2023-12-07 16:08:56 +0100
commita32bb8795a32367a95e7883fe61c8c9ccd085892 (patch)
tree135170cf3e7e39d9229c62e061f48c68e0bce236 /container-search
parent10a580357998b4c750729f27d3ef2e224dd69af7 (diff)
Detect integer fields in fieldsets.
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/YqlParser.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java7
2 files changed, 11 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java
index 4ea221446a4..29f2d9aff9a 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java
@@ -420,6 +420,10 @@ public class YqlParser implements Parser {
if (!index.isInteger() && !stringField)
throw new IllegalArgumentException("The in operator is only supported for integer and string fields. The field " +
field + " is not of these types");
+ if (index.isInteger() && stringField) {
+ throw new IllegalArgumentException("The in operator is not supported for fieldsets with a mix of integer and string fields. The fieldset " +
+ field + " has both");
+ }
Item item = null;
if (stringField) {
item = fillStringIn(ast, ast.getArgument(1), new StringInItem(field));
diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
index 178163cf961..783a0ec61de 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
@@ -90,6 +90,10 @@ public class YqlParserTestCase {
sd.addIndex(stringIndex);
Index floatIndex = new Index("float");
sd.addIndex(floatIndex);
+ Index mixedIndex = new Index("mixed");
+ mixedIndex.setInteger(true);
+ mixedIndex.setString(true);
+ sd.addIndex(mixedIndex);
return new IndexFacts(new IndexModel(sd));
}
@@ -1201,6 +1205,9 @@ public class YqlParserTestCase {
assertParseFail("select * from sources * where float in (25)",
new IllegalArgumentException("The in operator is only supported for integer and string fields. " +
"The field float is not of these types"));
+ assertParseFail("select * from sources * where mixed in (25)",
+ new IllegalArgumentException("The in operator is not supported for fieldsets with a mix of integer " +
+ "and string fields. The fieldset mixed has both"));
}
private static void assertNumericInItem(String field, long[] values, QueryTree query) {