aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-12-20 15:04:02 +0100
committerJon Bratseth <bratseth@gmail.com>2021-12-20 15:04:02 +0100
commit01dc74c762babd471a4d82aca4a7717fd0369120 (patch)
tree9fbeccaedaf80ddf65ac31315f2dcf6139ada026 /container-search
parente63125de6aa00bd671fc7c9b010dec786aacc64a (diff)
Don't require semicolon in YQL statements
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g42
-rw-r--r--container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java50
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java60
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java142
5 files changed, 121 insertions, 135 deletions
diff --git a/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4 b/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4
index 38efba3b511..8f4ed9d5ea3 100644
--- a/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4
+++ b/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4
@@ -174,7 +174,7 @@ keyword_as_ident
: SELECT | LIMIT | OFFSET | WHERE | 'order' | 'by' | DESC | OUTPUT | COUNT | SOURCES | MATCHES | LIKE
;
-program : (statement SEMI)* EOF
+program : (statement SEMI?)* EOF
;
moduleId
diff --git a/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java b/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java
index 6079c03ec5c..48dfa98768a 100644
--- a/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java
@@ -155,7 +155,7 @@ public class JSONSearchHandlerTestCase {
assertTrue("Do I have a new instance of the search handler?", searchHandler != newSearchHandler);
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) {
ObjectNode json = jsonMapper.createObjectNode();
- json.put("yql", "select * from foo where bar > 1453501295");
+ json.put("yql", "selectz * from foo where bar > 1453501295");
RequestHandlerTestDriver.MockResponseHandler responseHandler = newDriver.sendRequest(uri, com.yahoo.jdisc.http.HttpRequest.Method.POST, json.toString(), JSON_CONTENT_TYPE);
responseHandler.readAll();
assertThat(responseHandler.getStatus(), is(400));
diff --git a/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
index 09d1dc71249..fdd3bf6e1c9 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
@@ -68,7 +68,7 @@ public class MinimalQueryInserterTestCase {
assertEquals("foo", query.getPresentation().getSummaryFields().toArray(new String[1])[0]);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count())));");
+ "| all(group(a) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -76,7 +76,7 @@ public class MinimalQueryInserterTestCase {
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
"| all(group(a) each(output(count()))) " +
- "| all(group(b) each(output(count())));");
+ "| all(group(b) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -89,7 +89,7 @@ public class MinimalQueryInserterTestCase {
URIBuilder builder = new URIBuilder();
builder.setPath("search/");
- builder.setParameter("yql", "select foo from bar where baz contains 'cox';");
+ builder.setParameter("yql", "select foo from bar where baz contains 'cox'");
Query query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -97,7 +97,7 @@ public class MinimalQueryInserterTestCase {
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
"| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
- "all(group(a) each(output(count())));");
+ "all(group(a) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -107,7 +107,7 @@ public class MinimalQueryInserterTestCase {
"| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
"all(group(a) each(output(count()))) " +
"| [{ 'continuations':['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]" +
- "all(group(b) each(output(count())));");
+ "all(group(b) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -119,14 +119,14 @@ public class MinimalQueryInserterTestCase {
@Ignore
// TODO: YQL work in progress (jon)
public void testTmp() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
//execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
}
@Test
public void testSearch() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(Language.ENGLISH, query.getModel().getParsingLanguage());
@@ -135,7 +135,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testExplicitLanguageIsHonoredWithVerbatimQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?language=ja" + "&yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22%3B");
+ Query query = new Query("search/?language=ja" + "&yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("title:"+ japaneseWord, query.getModel().getQueryTree().toString());
@@ -144,7 +144,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserLanguageIsDetectedWithVerbatimQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22%3B");
+ Query query = new Query("search/?yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("title:"+ japaneseWord, query.getModel().getQueryTree().toString());
@@ -153,7 +153,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserLanguageIsDetectedWithUserInput() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?userString=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userInput(@userString)%3B");
+ Query query = new Query("search/?userString=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userInput(@userString)");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("AND title:madonna default:" + japaneseWord, query.getModel().getQueryTree().toString());
@@ -162,7 +162,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserLanguageIsDetectedWithUserQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?query=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("AND title:madonna " + japaneseWord, query.getModel().getQueryTree().toString());
@@ -170,14 +170,14 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserQueryFailsWithoutArgument() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
}
@Test
public void testSearchFromAllSourcesWithUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(0, query.getModel().getSources().size());
@@ -185,7 +185,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testSearchFromAllSourcesWithoutUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(0, query.getModel().getSources().size());
@@ -193,7 +193,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testSearchFromSomeSourcesWithoutUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(2, query.getModel().getSources().size());
@@ -203,7 +203,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testSearchFromSomeSourcesWithUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(3, query.getModel().getSources().size());
@@ -214,7 +214,7 @@ public class MinimalQueryInserterTestCase {
@Test
public final void testSearchFromSomeSourcesWithOverlappingUserSource() {
- final Query query = new Query("search/?query=easilyRecognizedString&sources=abc,sourceA&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ final Query query = new Query("search/?query=easilyRecognizedString&sources=abc,sourceA&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(3, query.getModel().getSources().size());
@@ -225,7 +225,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testLimitAndOffset() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2031offset%207%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2031offset%207");
execution.search(query);
assertEquals(7, query.getOffset());
assertEquals(24, query.getHits());
@@ -235,7 +235,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testMaxOffset() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040031offset%2040000%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040031offset%2040000");
Result r = execution.search(query);
assertEquals(1, r.hits().getErrorHit().errors().size());
ErrorMessage e = r.hits().getErrorHit().errorIterator().next();
@@ -245,7 +245,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testMaxLimit() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040000offset%207%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040000offset%207");
Result r = execution.search(query);
assertEquals(1, r.hits().getErrorHit().errors().size());
ErrorMessage e = r.hits().getErrorHit().errorIterator().next();
@@ -255,7 +255,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testTimeout() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20timeout%2051%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20timeout%2051");
execution.search(query);
assertEquals(51L, query.getTimeout());
assertEquals("select * from sources * where title contains \"madonna\" timeout 51;", query.yqlRepresentation());
@@ -281,7 +281,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testOrdering() {
{
- String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203%3B";
+ String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
assertEquals(2, query.getRanking().getSorting().fieldOrders()
@@ -297,7 +297,7 @@ public class MinimalQueryInserterTestCase {
assertEquals("select ignoredfield from ignoredsource where title contains \"madonna\" order by something, shoesize desc limit 300 timeout 3;", query.yqlRepresentation());
}
{
- String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20other%20limit%20300%20timeout%203%3B";
+ String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20other%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
assertEquals("other", query.getRanking().getSorting().fieldOrders()
@@ -307,7 +307,7 @@ public class MinimalQueryInserterTestCase {
assertEquals("select ignoredfield from ignoredsource where title contains \"madonna\" order by other limit 300 timeout 3;", query.yqlRepresentation());
}
{
- String yql = "select%20foo%20from%20bar%20where%20title%20contains%20%22madonna%22%20order%20by%20%5B%7B%22function%22%3A%20%22uca%22%2C%20%22locale%22%3A%20%22en_US%22%2C%20%22strength%22%3A%20%22IDENTICAL%22%7D%5Dother%20desc%2C%20%5B%7B%22function%22%3A%20%22lowercase%22%7D%5Dsomething%20limit%20300%20timeout%203%3B";
+ String yql = "select%20foo%20from%20bar%20where%20title%20contains%20%22madonna%22%20order%20by%20%5B%7B%22function%22%3A%20%22uca%22%2C%20%22locale%22%3A%20%22en_US%22%2C%20%22strength%22%3A%20%22IDENTICAL%22%7D%5Dother%20desc%2C%20%5B%7B%22function%22%3A%20%22lowercase%22%7D%5Dsomething%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
{
@@ -334,7 +334,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testStringRepresentation() {
- String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203%3B";
+ String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
assertEquals("select ignoredfield from ignoredsource where title contains \"madonna\" order by something, shoesize desc limit 300 timeout 3;",
diff --git a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
index 3eb6f5e7e38..981a79aa9fc 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
@@ -48,24 +48,21 @@ public class UserInputTestCase {
public void testSimpleUserInput() {
{
URIBuilder builder = searchUri();
- builder.setParameter("yql",
- "select * from sources * where userInput(\"nalle\");");
+ builder.setParameter("yql", "select * from sources * where userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"nalle\";", query.yqlRepresentation());
}
{
URIBuilder builder = searchUri();
builder.setParameter("nalle", "bamse");
- builder.setParameter("yql",
- "select * from sources * where userInput(@nalle);");
+ builder.setParameter("yql", "select * from sources * where userInput(@nalle)");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"bamse\";", query.yqlRepresentation());
}
{
URIBuilder builder = searchUri();
builder.setParameter("nalle", "bamse");
- builder.setParameter("yql",
- "select * from sources * where userInput(nalle);");
+ builder.setParameter("yql", "select * from sources * where userInput(nalle)");
Query query = new Query(builder.toString());
Result r = execution.search(query);
assertNotNull(r.hits().getError());
@@ -75,8 +72,7 @@ public class UserInputTestCase {
@Test
public void testRawUserInput() {
URIBuilder builder = searchUri();
- builder.setParameter("yql",
- "select * from sources * where [{\"grammar\": \"raw\"}]userInput(\"nal le\");");
+ builder.setParameter("yql", "select * from sources * where [{\"grammar\": \"raw\"}]userInput(\"nal le\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"nal le\";", query.yqlRepresentation());
}
@@ -85,7 +81,7 @@ public class UserInputTestCase {
public void testSegmentedUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"grammar\": \"segment\"}]userInput(\"nal le\");");
+ "select * from sources * where [{\"grammar\": \"segment\"}]userInput(\"nal le\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains ([{\"origin\": {\"original\": \"nal le\", \"offset\": 0, \"length\": 6}}]phrase(\"nal\", \"le\"));", query.yqlRepresentation());
}
@@ -94,7 +90,7 @@ public class UserInputTestCase {
public void testSegmentedNoiseUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"grammar\": \"segment\"}]userInput(\"^^^^^^^^\");");
+ "select * from sources * where [{\"grammar\": \"segment\"}]userInput(\"^^^^^^^^\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"^^^^^^^^\";", query.yqlRepresentation());
}
@@ -103,7 +99,7 @@ public class UserInputTestCase {
public void testCustomDefaultIndexUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"defaultIndex\": \"glompf\"}]userInput(\"nalle\");");
+ "select * from sources * where [{\"defaultIndex\": \"glompf\"}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where glompf contains \"nalle\";", query.yqlRepresentation());
}
@@ -112,7 +108,7 @@ public class UserInputTestCase {
public void testAnnotatedUserInputStemming() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"stem\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{\"stem\": false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
"select * from sources * where default contains ([{\"stem\": false}]\"nalle\");",
@@ -124,7 +120,7 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter("myinput", "-5");
builder.setParameter("yql",
- "select * from ecitem where rank(([{\"defaultIndex\":\"myfield\"}](userInput(@myinput))));");
+ "select * from ecitem where rank(([{\"defaultIndex\":\"myfield\"}](userInput(@myinput))))");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from ecitem where rank(myfield = (-5));", query.yqlRepresentation());
assertEquals("RANK myfield:-5", query.getModel().getQueryTree().getRoot().toString());
@@ -134,7 +130,7 @@ public class UserInputTestCase {
public void testAnnotatedUserInputUnrankedTerms() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"ranked\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{\"ranked\": false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
"select * from sources * where default contains ([{\"ranked\": false}]\"nalle\");",
@@ -145,7 +141,7 @@ public class UserInputTestCase {
public void testAnnotatedUserInputFiltersTerms() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"filter\": true}]userInput(\"nalle\");");
+ "select * from sources * where [{\"filter\": true}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
"select * from sources * where default contains ([{\"filter\": true}]\"nalle\");",
@@ -157,7 +153,7 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter(
"yql",
- "select * from sources * where [{\"normalizeCase\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{\"normalizeCase\": false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
"select * from sources * where default contains ([{\"normalizeCase\": false}]\"nalle\");",
@@ -168,7 +164,7 @@ public class UserInputTestCase {
public void testAnnotatedUserInputAccentRemoval() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"accentDrop\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{\"accentDrop\": false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
"select * from sources * where default contains ([{\"accentDrop\": false}]\"nalle\");",
@@ -179,7 +175,7 @@ public class UserInputTestCase {
public void testAnnotatedUserInputPositionData() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"usePositionData\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{\"usePositionData\": false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
"select * from sources * where default contains ([{\"usePositionData\": false}]\"nalle\");",
@@ -192,7 +188,7 @@ public class UserInputTestCase {
builder.setParameter("nalle", "bamse");
builder.setParameter("meta", "syntactic");
builder.setParameter("yql",
- "select * from sources * where foo contains @nalle and foo contains phrase(@nalle, @meta, @nalle);");
+ "select * from sources * where foo contains @nalle and foo contains phrase(@nalle, @meta, @nalle)");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where (foo contains \"bamse\" AND foo contains phrase(\"bamse\", \"syntactic\", \"bamse\"));", query.yqlRepresentation());
}
@@ -201,7 +197,7 @@ public class UserInputTestCase {
public void testReferenceInComparison() {
URIBuilder builder = searchUri();
builder.setParameter("varref", "1980");
- builder.setParameter("yql", "select * from sources * where year > @varref;");
+ builder.setParameter("yql", "select * from sources * where year > @varref");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where year > 1980;", query.yqlRepresentation());
}
@@ -212,7 +208,7 @@ public class UserInputTestCase {
builder.setParameter("continuation", "BCBCBCBEBG");
builder.setParameter("yql",
"select * from sources * where myfield contains 'token'" +
- "| [{'continuations':[@continuation, 'BCBKCBACBKCCK'] }] all(group(f) each(output(count())));");
+ "| [{'continuations':[@continuation, 'BCBKCBACBKCCK'] }] all(group(f) each(output(count())))");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where myfield contains \"token\" | [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(f) each(output(count())));", query.yqlRepresentation());
}
@@ -222,7 +218,7 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter("term", "A");
builder.setParameter("yql",
- "select foo from bar where fieldName contains equiv(@term,'B');");
+ "select foo from bar where fieldName contains equiv(@term,'B')");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select foo from bar where fieldName contains equiv(\"A\", \"B\");", query.yqlRepresentation());
}
@@ -249,7 +245,7 @@ public class UserInputTestCase {
@Test
public void testEmptyUserInput() {
URIBuilder builder = searchUri();
- builder.setParameter("yql", "select * from sources * where userInput(\"\");");
+ builder.setParameter("yql", "select * from sources * where userInput(\"\")");
assertQueryFails(builder);
}
@@ -257,7 +253,7 @@ public class UserInputTestCase {
public void testEmptyUserInputFromQueryProperty() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
- builder.setParameter("yql", "select * from sources * where userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where userInput(@foo)");
assertQueryFails(builder);
}
@@ -265,7 +261,7 @@ public class UserInputTestCase {
public void testEmptyQueryProperty() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
- builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains @foo);");
+ builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains @foo)");
assertQueryFails(builder);
}
@@ -274,17 +270,17 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
builder.setParameter("yql",
- "select * from sources * where bar contains \"a\" and nonEmpty(bar contains \"bar\" and foo contains @foo);");
+ "select * from sources * where bar contains \"a\" and nonEmpty(bar contains \"bar\" and foo contains @foo)");
assertQueryFails(builder);
}
@Test
public void testCompositeWithoutArguments() {
URIBuilder builder = searchUri();
- builder.setParameter("yql", "select * from sources * where bar contains \"a\" and foo contains phrase();");
+ builder.setParameter("yql", "select * from sources * where bar contains \"a\" and foo contains phrase()");
searchAndAssertNoErrors(builder);
builder = searchUri();
- builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains phrase());");
+ builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains phrase())");
assertQueryFails(builder);
}
@@ -292,7 +288,7 @@ public class UserInputTestCase {
public void testAnnoyingPlacementOfNonEmpty() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where bar contains \"a\" and foo contains nonEmpty(phrase(\"a\", \"b\"));");
+ "select * from sources * where bar contains \"a\" and foo contains nonEmpty(phrase(\"a\", \"b\"))");
assertQueryFails(builder);
}
@@ -305,7 +301,7 @@ public class UserInputTestCase {
public void testAllowEmptyUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
- builder.setParameter("yql", "select * from sources * where [{\"allowEmpty\": true}]userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where [{\"allowEmpty\": true}]userInput(@foo)");
searchAndAssertNoErrors(builder);
}
@@ -313,7 +309,7 @@ public class UserInputTestCase {
public void testAllowEmptyNullFromQueryParsing() {
URIBuilder builder = searchUri();
builder.setParameter("foo", ",,,,,,,,");
- builder.setParameter("yql", "select * from sources * where [{\"allowEmpty\": true}]userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where [{\"allowEmpty\": true}]userInput(@foo)");
searchAndAssertNoErrors(builder);
}
@@ -321,7 +317,7 @@ public class UserInputTestCase {
public void testDisallowEmptyNullFromQueryParsing() {
URIBuilder builder = searchUri();
builder.setParameter("foo", ",,,,,,,,");
- builder.setParameter("yql", "select * from sources * where userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where userInput(@foo)");
assertQueryFails(builder);
}
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 2a21214c702..0513179d10d 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
@@ -71,7 +71,7 @@ public class YqlParserTestCase {
@Test(timeout = 120_000)
public void failsGracefullyOnMissingQuoteEscapingAndSubsequentUnicodeCharacter() {
- assertParseFail("select * from bar where rank(ids contains 'http://en.wikipedia.org/wiki/Hors_d'œuvre') limit 10;",
+ assertParseFail("select * from bar where rank(ids contains 'http://en.wikipedia.org/wiki/Hors_d'œuvre') limit 10",
new IllegalInputException("com.yahoo.search.yql.ProgramCompileException: query:L1:79 token recognition error at: 'œ'"));
}
@@ -84,13 +84,13 @@ public class YqlParserTestCase {
@Test
public void testLanguageDetection() {
// SimpleDetector used here can detect japanese and will set that as language at the root of the user input
- QueryTree tree = parse("select * from sources * where userInput(\"\u30ab\u30bf\u30ab\u30ca\");");
+ QueryTree tree = parse("select * from sources * where userInput(\"\u30ab\u30bf\u30ab\u30ca\")");
assertEquals(Language.JAPANESE, tree.getRoot().getLanguage());
}
@Test
public void testGroupingStep() {
- assertParse("select foo from bar where baz contains 'cox';",
+ assertParse("select foo from bar where baz contains 'cox'",
"baz:cox");
assertEquals("[]",
toString(parser.getGroupingSteps()));
@@ -113,14 +113,14 @@ public class YqlParserTestCase {
@Test
public void testGroupingContinuation() {
assertParse("select foo from bar where baz contains 'cox' " +
- "| [{ 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(a) each(output(count())));",
+ "| [{ 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(a) each(output(count())))",
"baz:cox");
assertEquals("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))]",
toString(parser.getGroupingSteps()));
assertParse("select foo from bar where baz contains 'cox' " +
"| [{ 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(a) each(output(count()))) " +
- "| [{ 'continuations': ['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]all(group(b) each(output(count())));",
+ "| [{ 'continuations': ['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]all(group(b) each(output(count())))",
"baz:cox");
assertEquals("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))," +
" [BCBBBBBDBF, BCBJBPCBJCCJ]all(group(b) each(output(count())))]",
@@ -194,8 +194,8 @@ public class YqlParserTestCase {
@Test
public void testLessThan() {
- assertParse("select foo from bar where price < 500;", "price:<500");
- assertParse("select foo from bar where 500 < price;", "price:>500");
+ assertParse("select foo from bar where price < 500", "price:<500");
+ assertParse("select foo from bar where 500 < price", "price:>500");
}
@Test
@@ -206,8 +206,8 @@ public class YqlParserTestCase {
@Test
public void testLessThanOrEqual() {
- assertParse("select foo from bar where price <= 500;", "price:[;500]");
- assertParse("select foo from bar where 500 <= price;", "price:[500;]");
+ assertParse("select foo from bar where price <= 500", "price:[;500]");
+ assertParse("select foo from bar where 500 <= price", "price:[500;]");
}
@Test
@@ -690,80 +690,72 @@ public class YqlParserTestCase {
@Test
public void testLongNumberInSimpleExpression() {
- assertParse("select foo from bar where price = 8589934592L;",
- "price:8589934592");
+ assertParse("select foo from bar where price = 8589934592L", "price:8589934592");
}
@Test
public void testNegativeLongNumberInSimpleExpression() {
- assertParse("select foo from bar where price = -8589934592L;",
- "price:-8589934592");
+ assertParse("select foo from bar where price = -8589934592L", "price:-8589934592");
}
@Test
public void testSources() {
- assertSources("select foo from sourceA where price <= 500;",
- Arrays.asList("sourceA"));
+ assertSources("select foo from sourceA where price <= 500", List.of("sourceA"));
+ }
+
+ @Test
+ public void testQueryWithSemicolon() {
+ assertParse("select foo from bar where price = 1;", "price:1");
}
@Test
public void testSourcesWithDash() {
- assertSources("select foo from source-a where price <= 500;",
- Arrays.asList("source-a"));
+ assertSources("select foo from source-a where price <= 500", List.of("source-a"));
}
@Test
public void testWildCardSources() {
- assertSources("select foo from sources * where price <= 500;",
- Collections.<String>emptyList());
+ assertSources("select foo from sources * where price <= 500", List.of());
}
@Test
public void testMultiSources() {
- assertSources("select foo from sources sourceA, sourceB where price <= 500;",
- Arrays.asList("sourceA", "sourceB"));
+ assertSources("select foo from sources sourceA, sourceB where price <= 500", List.of("sourceA", "sourceB"));
}
@Test
public void testFields() {
- assertSummaryFields("select fieldA from bar where price <= 500;",
- Arrays.asList("fieldA"));
- assertSummaryFields("select fieldA, fieldB from bar where price <= 500;",
- Arrays.asList("fieldA", "fieldB"));
- assertSummaryFields("select fieldA, fieldB, fieldC from bar where price <= 500;",
- Arrays.asList("fieldA", "fieldB", "fieldC"));
- assertSummaryFields("select * from bar where price <= 500;",
- Collections.<String>emptyList());
+ assertSummaryFields("select fieldA from bar where price <= 500", List.of("fieldA"));
+ assertSummaryFields("select fieldA, fieldB from bar where price <= 500", List.of("fieldA", "fieldB"));
+ assertSummaryFields("select fieldA, fieldB, fieldC from bar where price <= 500", List.of("fieldA", "fieldB", "fieldC"));
+ assertSummaryFields("select * from bar where price <= 500", List.of());
}
@Test
public void testFieldsRoot() {
- assertParse("select * from bar where price <= 500;",
- "price:[;500]");
+ assertParse("select * from bar where price <= 500", "price:[;500]");
}
@Test
public void testOffset() {
- assertParse("select foo from bar where title contains \"madonna\" offset 37;",
- "title:madonna");
+ assertParse("select foo from bar where title contains \"madonna\" offset 37", "title:madonna");
assertEquals(Integer.valueOf(37), parser.getOffset());
}
@Test
public void testLimit() {
- assertParse("select foo from bar where title contains \"madonna\" limit 29;",
- "title:madonna");
+ assertParse("select foo from bar where title contains \"madonna\" limit 29", "title:madonna");
assertEquals(Integer.valueOf(29), parser.getHits());
}
@Test
public void testOffsetAndLimit() {
- assertParse("select foo from bar where title contains \"madonna\" limit 31 offset 29;",
+ assertParse("select foo from bar where title contains \"madonna\" limit 31 offset 29",
"title:madonna");
assertEquals(Integer.valueOf(29), parser.getOffset());
assertEquals(Integer.valueOf(2), parser.getHits());
- assertParse("select * from bar where title contains \"madonna\" limit 41 offset 37;",
+ assertParse("select * from bar where title contains \"madonna\" limit 41 offset 37",
"title:madonna");
assertEquals(Integer.valueOf(37), parser.getOffset());
assertEquals(Integer.valueOf(4), parser.getHits());
@@ -771,19 +763,17 @@ public class YqlParserTestCase {
@Test
public void testTimeout() {
- assertParse("select * from bar where title contains \"madonna\" timeout 7;",
- "title:madonna");
+ assertParse("select * from bar where title contains \"madonna\" timeout 7", "title:madonna");
assertEquals(Integer.valueOf(7), parser.getTimeout());
- assertParse("select foo from bar where title contains \"madonna\" limit 600 timeout 3;",
- "title:madonna");
+ assertParse("select foo from bar where title contains \"madonna\" limit 600 timeout 3", "title:madonna");
assertEquals(Integer.valueOf(3), parser.getTimeout());
}
@Test
public void testOrdering() {
assertParse("select foo from bar where title contains \"madonna\" order by something asc, " +
- "shoesize desc limit 600 timeout 3;",
+ "shoesize desc limit 600 timeout 3",
"title:madonna");
assertEquals(2, parser.getSorting().fieldOrders().size());
assertEquals("something", parser.getSorting().fieldOrders().get(0).getFieldName());
@@ -792,7 +782,7 @@ public class YqlParserTestCase {
assertEquals(Order.DESCENDING, parser.getSorting().fieldOrders().get(1).getSortOrder());
assertParse("select foo from bar where title contains \"madonna\" order by other limit 600 " +
- "timeout 3;",
+ "timeout 3",
"title:madonna");
assertEquals("other", parser.getSorting().fieldOrders().get(0).getFieldName());
assertEquals(Order.ASCENDING, parser.getSorting().fieldOrders().get(0).getSortOrder());
@@ -803,7 +793,7 @@ public class YqlParserTestCase {
assertParse(
"select foo from bar where title contains \"madonna\""
+ " order by [{\"function\": \"uca\", \"locale\": \"en_US\", \"strength\": \"IDENTICAL\"}]other desc"
- + " limit 600" + " timeout 3;", "title:madonna");
+ + " limit 600" + " timeout 3", "title:madonna");
FieldOrder fieldOrder = parser.getSorting().fieldOrders().get(0);
assertEquals("other", fieldOrder.getFieldName());
assertEquals(Order.DESCENDING, fieldOrder.getSortOrder());
@@ -820,7 +810,7 @@ public class YqlParserTestCase {
"select foo from bar where title contains \"madonna\""
+ " order by [{\"function\": \"uca\", \"locale\": \"en_US\", \"strength\": \"IDENTICAL\"}]other desc,"
+ " [{\"function\": \"lowercase\"}]something asc"
- + " limit 600" + " timeout 3;", "title:madonna");
+ + " limit 600" + " timeout 3", "title:madonna");
{
FieldOrder fieldOrder = parser.getSorting().fieldOrders().get(0);
assertEquals("other", fieldOrder.getFieldName());
@@ -842,29 +832,29 @@ public class YqlParserTestCase {
@Test
public void testSegmenting() {
- assertParse("select * from bar where title contains 'foo.bar';",
- "title:'foo bar'");
-
- assertParse("select * from bar where title contains 'foo&123';",
- "title:'foo 123'");
+ assertParse("select * from bar where title contains 'foo.bar'", "title:'foo bar'");
+ assertParse("select * from bar where title contains 'foo&123'", "title:'foo 123'");
}
@Test
public void testNegativeHitLimit() {
- assertParse("select * from sources * where [{\"hitLimit\": -38}]range(foo, 0, 1);",
- "foo:[0;1;-38]");
+ assertParse("select * from sources * where [{\"hitLimit\": -38}]range(foo, 0, 1)", "foo:[0;1;-38]");
}
@Test
public void testRangeSearchHitPopulationOrdering() {
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": true}]range(foo, 0, 1);", "foo:[0;1;38]");
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": false}]range(foo, 0, 1);", "foo:[0;1;-38]");
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"descending\": true}]range(foo, 0, 1);", "foo:[0;1;-38]");
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"descending\": false}]range(foo, 0, 1);", "foo:[0;1;38]");
+ assertParse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": true}]range(foo, 0, 1)",
+ "foo:[0;1;38]");
+ assertParse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": false}]range(foo, 0, 1)",
+ "foo:[0;1;-38]");
+ assertParse("select * from sources * where [{\"hitLimit\": 38, \"descending\": true}]range(foo, 0, 1)",
+ "foo:[0;1;-38]");
+ assertParse("select * from sources * where [{\"hitLimit\": 38, \"descending\": false}]range(foo, 0, 1)",
+ "foo:[0;1;38]");
boolean gotExceptionFromParse = false;
try {
- parse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": true, \"descending\": false}]range(foo, 0, 1);");
+ parse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": true, \"descending\": false}]range(foo, 0, 1)");
} catch (IllegalArgumentException e) {
assertTrue("Expected information about abuse of settings.",
e.getMessage().contains("both ascending and descending ordering set"));
@@ -875,23 +865,23 @@ public class YqlParserTestCase {
@Test
public void testOpenIntervals() {
- assertParse("select * from sources * where range(title, 0.0, 500.0);",
+ assertParse("select * from sources * where range(title, 0.0, 500.0)",
"title:[0.0;500.0]");
assertParse(
- "select * from sources * where [{\"bounds\": \"open\"}]range(title, 0.0, 500.0);",
+ "select * from sources * where [{\"bounds\": \"open\"}]range(title, 0.0, 500.0)",
"title:<0.0;500.0>");
assertParse(
- "select * from sources * where [{\"bounds\": \"leftOpen\"}]range(title, 0.0, 500.0);",
+ "select * from sources * where [{\"bounds\": \"leftOpen\"}]range(title, 0.0, 500.0)",
"title:<0.0;500.0]");
assertParse(
- "select * from sources * where [{\"bounds\": \"rightOpen\"}]range(title, 0.0, 500.0);",
+ "select * from sources * where [{\"bounds\": \"rightOpen\"}]range(title, 0.0, 500.0)",
"title:[0.0;500.0>");
}
@Test
public void testInheritedAnnotations() {
{
- QueryTree x = parse("select * from sources * where ([{\"ranked\": false}](foo contains \"a\" and bar contains \"b\")) or foor contains ([{\"ranked\": false}]\"c\");");
+ QueryTree x = parse("select * from sources * where ([{\"ranked\": false}](foo contains \"a\" and bar contains \"b\")) or foor contains ([{\"ranked\": false}]\"c\")");
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(3, terms.size());
for (IndexedItem term : terms) {
@@ -899,7 +889,7 @@ public class YqlParserTestCase {
}
}
{
- QueryTree x = parse("select * from sources * where [{\"ranked\": false}](foo contains \"a\" and bar contains \"b\");");
+ QueryTree x = parse("select * from sources * where [{\"ranked\": false}](foo contains \"a\" and bar contains \"b\")");
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(2, terms.size());
for (IndexedItem term : terms) {
@@ -914,7 +904,7 @@ public class YqlParserTestCase {
"([{\"ranked\": false}](foo contains \"a\" " +
"and ([{\"ranked\": true}](bar contains \"b\" " +
"or ([{\"ranked\": false}](foo contains \"c\" " +
- "and foo contains ([{\"ranked\": true}]\"d\")))))));";
+ "and foo contains ([{\"ranked\": true}]\"d\")))))))";
QueryTree x = parse(yqlQuery);
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(4, terms.size());
@@ -945,7 +935,7 @@ public class YqlParserTestCase {
ParserEnvironment parserEnvironment = new ParserEnvironment().setIndexFacts(indexFacts);
YqlParser configuredParser = new YqlParser(parserEnvironment);
QueryTree x = configuredParser.parse(new Parsable()
- .setQuery("select * from sources * where title contains \"a\" and song contains \"b\";"));
+ .setQuery("select * from sources * where title contains \"a\" and song contains \"b\""));
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(2, terms.size());
for (IndexedItem term : terms) {
@@ -955,7 +945,7 @@ public class YqlParserTestCase {
@Test
public void testRegexp() {
- QueryTree x = parse("select * from sources * where foo matches \"a b\";");
+ QueryTree x = parse("select * from sources * where foo matches \"a b\"");
Item root = x.getRoot();
assertSame(RegExpItem.class, root.getClass());
assertEquals("a b", ((RegExpItem) root).stringValue());
@@ -963,7 +953,7 @@ public class YqlParserTestCase {
@Test
public void testWordAlternatives() {
- QueryTree x = parse("select * from sources * where foo contains alternatives({\"trees\": 1.0, \"tree\": 0.7});");
+ QueryTree x = parse("select * from sources * where foo contains alternatives({\"trees\": 1.0, \"tree\": 0.7})");
Item root = x.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
WordAlternativesItem alternatives = (WordAlternativesItem) root;
@@ -974,7 +964,7 @@ public class YqlParserTestCase {
public void testWordAlternativesWithOrigin() {
QueryTree q = parse("select * from sources * where foo contains" +
" ([{\"origin\": {\"original\": \" trees \", \"offset\": 1, \"length\": 5}}]" +
- "alternatives({\"trees\": 1.0, \"tree\": 0.7}));");
+ "alternatives({\"trees\": 1.0, \"tree\": 0.7}))");
Item root = q.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
WordAlternativesItem alternatives = (WordAlternativesItem) root;
@@ -989,7 +979,7 @@ public class YqlParserTestCase {
@Test
public void testWordAlternativesInPhrase() {
QueryTree q = parse("select * from sources * where" +
- " foo contains phrase(\"forest\", alternatives({\"trees\": 1.0, \"tree\": 0.7}));");
+ " foo contains phrase(\"forest\", alternatives({\"trees\": 1.0, \"tree\": 0.7}))");
Item root = q.getRoot();
assertSame(PhraseItem.class, root.getClass());
PhraseItem phrase = (PhraseItem) root;
@@ -1011,7 +1001,7 @@ public class YqlParserTestCase {
}
{
- Query query = new Query("search?yql=select%20*%20from%20testtype%20where%20title%20contains%20%22%5C%5C%22;");
+ Query query = new Query("search?yql=select%20*%20from%20testtype%20where%20title%20contains%20%22%5C%5C%22");
// Cause parsing :-\
Chain<Searcher> searchChain = new Chain<>(new MinimalQueryInserter());
@@ -1030,7 +1020,7 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield.hostname contains uri(\"google.com\");");
+ yql.properties().set("yql", "select * from sources * where urlfield.hostname contains uri(\"google.com\")");
assertUrlQuery("urlfield.hostname", yql, false, true, true);
}
@@ -1041,7 +1031,7 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{\"endAnchor\": false }]uri(\"google.com\"));");
+ yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{\"endAnchor\": false }]uri(\"google.com\"))");
assertUrlQuery("urlfield.hostname", yql, false, false, true);
}
@@ -1052,7 +1042,7 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{\"startAnchor\": true }] uri(\"google.com\"));");
+ yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{\"startAnchor\": true }] uri(\"google.com\"))");
assertUrlQuery("urlfield.hostname", yql, true, true, true);
}
@@ -1063,19 +1053,19 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield contains uri(\"google.com\");");
+ yql.properties().set("yql", "select * from sources * where urlfield contains uri(\"google.com\")");
assertUrlQuery("urlfield", yql, false, false, false);
}
@Test
public void testReservedWordInSource() {
- parse("select * from sources like where text contains \"test\";");
+ parse("select * from sources like where text contains \"test\"");
// success: parsed without exception
}
@Test
public void testAndSegmenting() {
- parse("select * from sources * where (default contains ([{\"stem\": false}]\"m\") AND default contains ([{\"origin\": {\"original\": \"m\'s\", \"offset\": 0, \"length\": 3}, \"andSegmenting\": true}]phrase(\"m\", \"s\"))) timeout 472;");
+ parse("select * from sources * where (default contains ([{\"stem\": false}]\"m\") AND default contains ([{\"origin\": {\"original\": \"m\'s\", \"offset\": 0, \"length\": 3}, \"andSegmenting\": true}]phrase(\"m\", \"s\"))) timeout 472");
}
private void assertUrlQuery(String field, Query query, boolean startAnchor, boolean endAnchor, boolean endAnchorIsDefault) {