diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-09-13 14:52:09 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-09-13 14:52:09 +0200 |
commit | bfa97cd7db05e1f38a2fba7c5f834398eb9fd573 (patch) | |
tree | 95b71682cb017333447a488ef015ea12146abb2d /container-search/src | |
parent | c7d8f1d90ff8904e5449f62c3482a93d1dc8049f (diff) |
Nonfunctional changes only
Diffstat (limited to 'container-search/src')
7 files changed, 42 insertions, 42 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/RangeItem.java b/container-search/src/main/java/com/yahoo/prelude/query/RangeItem.java index 737f36e2553..419471348b7 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/RangeItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/RangeItem.java @@ -11,7 +11,6 @@ package com.yahoo.prelude.query; * * @author baldersheim * @author bratseth - * @since 5.1.23 */ // Note that this is just a convenience subclass of IntItem - it does not add any functionality not available in it. public class RangeItem extends IntItem { diff --git a/container-search/src/main/java/com/yahoo/prelude/query/SimpleIndexedItem.java b/container-search/src/main/java/com/yahoo/prelude/query/SimpleIndexedItem.java index a1ab3f1ef92..4b66d0d757b 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/SimpleIndexedItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/SimpleIndexedItem.java @@ -44,6 +44,7 @@ public abstract class SimpleIndexedItem extends SimpleTaggableItem implements In if (index == null) { index = ""; } + this.index = index; } diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/StructuredParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/StructuredParser.java index 7da2e4c3240..ec1f79828c1 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/StructuredParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/StructuredParser.java @@ -16,6 +16,7 @@ import static com.yahoo.prelude.query.parser.Token.Kind.*; * for structured queries (types ANY, ALL and ADVANCED). * * @author Steinar Knutsen + * @author bratseth */ abstract class StructuredParser extends AbstractParser { @@ -320,25 +321,19 @@ abstract class StructuredParser extends AbstractParser { private IntItem numberRange() { int position = tokens.getPosition(); IntItem item = null; - boolean negative = false; try { Token initial = tokens.next(); - if (initial.kind != LSQUAREBRACKET) { - return null; - } + if (initial.kind != LSQUAREBRACKET) return null; String rangeStart = ""; - - negative = tokens.skip(MINUS); + boolean negative = tokens.skip(MINUS); if (tokens.currentIs(NUMBER)) { rangeStart = (negative ? "-" : "") + tokens.next().toString() + decimalPart(); } - if (!tokens.skip(SEMICOLON)) { - return null; - } + if (!tokens.skip(SEMICOLON)) return null; String rangeEnd = ""; @@ -374,17 +369,13 @@ abstract class StructuredParser extends AbstractParser { private IntItem numberSmaller() { int position = tokens.getPosition(); IntItem item = null; - boolean negative = false; try { Token initial = tokens.next(); - if (initial.kind != SMALLER) { - return null; - } - negative = tokens.skipNoIgnore(MINUS); - if (!tokens.currentIs(NUMBER)) { - return null; - } + if (initial.kind != SMALLER) return null; + + boolean negative = tokens.skipNoIgnore(MINUS); + if ( ! tokens.currentIs(NUMBER)) return null; item = new IntItem("<" + (negative ? "-" : "") + tokens.next() + decimalPart(), true); item.setOrigin(new Substring(initial.substring.start, tokens.currentNoIgnore().substring.start, @@ -400,22 +391,17 @@ abstract class StructuredParser extends AbstractParser { private IntItem numberGreater() { int position = tokens.getPosition(); IntItem item = null; - boolean negative = false; try { - Token t = tokens.next(); - if (t.kind != GREATER) { - return null; - } + Token initial = tokens.next(); + if (initial.kind != GREATER) return null; - negative = tokens.skipNoIgnore(MINUS); - if (!tokens.currentIs(NUMBER)) { - return null; - } + boolean negative = tokens.skipNoIgnore(MINUS); + if ( ! tokens.currentIs(NUMBER)) return null; - Token number = tokens.next(); - item = new IntItem(">" + (negative ? "-" : "") + number + decimalPart(), true); - item.setOrigin(new Substring(t.substring.start, tokens.currentNoIgnore().substring.start, t.getSubstring().getSuperstring())); // XXX: Unsafe end? + item = new IntItem(">" + (negative ? "-" : "") + tokens.next() + decimalPart(), true); + item.setOrigin(new Substring(initial.substring.start, tokens.currentNoIgnore().substring.start, + initial.getSubstring().getSuperstring())); // XXX: Unsafe end? return item; } finally { if (item == null) { diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java index 53b39046f1d..adf01f161a4 100644 --- a/container-search/src/main/java/com/yahoo/search/Query.java +++ b/container-search/src/main/java/com/yahoo/search/Query.java @@ -400,7 +400,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { * of tracelevel, which is the property deciding whether this needs to be done */ private void traceProperties() { - if (traceLevel==0) return; + if (traceLevel == 0) return; CompiledQueryProfile profile=null; QueryProfileProperties profileProperties=properties().getInstance(QueryProfileProperties.class); if (profileProperties!=null) @@ -410,10 +410,10 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { trace("No query profile is used", false, 1); else trace("Using " + profile.toString(), false, 1); - if (traceLevel<4) return; + if (traceLevel < 4) return; - StringBuilder b=new StringBuilder("Resolved properties:\n"); - Set<String> mentioned=new HashSet<>(); + StringBuilder b = new StringBuilder("Resolved properties:\n"); + Set<String> mentioned = new HashSet<>(); for (Map.Entry<String,String> requestProperty : requestProperties().entrySet() ) { Object resolvedValue = properties().get(requestProperty.getKey(), requestProperties()); if (resolvedValue == null && requestProperty.getKey().equals("queryProfile")) diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java index 86c62715c8f..9181ea4e268 100644 --- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java @@ -303,15 +303,32 @@ public class ParseTestCase { } @Test + public void testGreaterNumericWithIndex() { + IntItem item = (IntItem)tester.assertParsed("score:<454", "score:<454", Query.Type.ANY); + assertEquals("score", item.getIndexName()); + assertEquals(454L, item.getToLimit().number()); + assertFalse(item.getToLimit().isInclusive()); + } + + @Test public void testSmallerNumeric() { tester.assertParsed(">454", ">454", Query.Type.ANY); } @Test + public void testSmallerNumericWithIndex() { + IntItem item = (IntItem)tester.assertParsed("score:>454", "score:>454", Query.Type.ANY); + assertEquals("score", item.getIndexName()); + assertEquals(454L, item.getFromLimit().number()); + assertFalse(item.getFromLimit().isInclusive()); + } + + @Test public void testFullRange() { tester.assertParsed("[34;454]", "[34;454]", Query.Type.ANY); } + @Test public void testFullRangeLimit() { tester.assertParsed("[34;454;7]", "[34;454;7]", Query.Type.ANY); tester.assertParsed("[34;454;-7]", "[34;454;-7]", Query.Type.ANY); @@ -351,7 +368,7 @@ public class ParseTestCase { Query.Type.ANY); } - /** Test 50. Semantics changed: Old parser: OR to be or not */ + @Test public void testEmptyPhrase() { tester.assertParsed("\"to be or not\"", "\"\"to be or not", Query.Type.ANY); } @@ -1889,7 +1906,6 @@ public class ParseTestCase { Query.Type.ALL); } - // Ticket 523571 @Test public void testParensInQuotes() { tester.assertParsed("AND ringtone (OR a:\"Delivery SMAF large max 150kB 063\" a:\"RealMusic Delivery\")", @@ -2146,7 +2162,6 @@ public class ParseTestCase { Query.Type.ADVANCED); } - // bug 2530430 // This test is here instead of in the query parser because // this needs to become series of tests where the tokenizer // and parser will step on each other's toes. @@ -2301,7 +2316,6 @@ public class ParseTestCase { tester.assertParsed(null, "-12.2", Query.Type.WEB); } - /** These additions should be done by the YstSearcher */ @Test public void testDefaultWebIndices() { tester.assertParsed("\"notanindex b\"","notanindex:b",Query.Type.WEB); @@ -2457,7 +2471,7 @@ public class ParseTestCase { @Test public void testTwoRanges() { - tester.assertParsed("AND score:[1.25;2.18] age:[25;30]","score:[1.25;2.18] AND age:[25;30]",Query.Type.ADVANCED); + tester.assertParsed("AND score:[1.25;2.18] age:[25;30]","score:[1.25;2.18] AND age:[25;30]", Query.Type.ADVANCED); } @Test diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java index fdfebeb74a8..4802a3a2cb5 100644 --- a/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java @@ -14,8 +14,8 @@ public class RangeItemTestCase { @Test public void testRangeConstruction() { verifyRange(new RangeItem(5, 7, 9, "a", true), 9, true); - verifyRange(new RangeItem(5,7, "a", true), 0, true); - verifyRange(new RangeItem(5,7, "a"), 0, false); + verifyRange(new RangeItem(5, 7, "a", true), 0, true); + verifyRange(new RangeItem(5, 7, "a"), 0, false); } private void verifyRange(RangeItem range, int limit, boolean isFromQuery) { diff --git a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java index 2528514bc98..2d46ff8e177 100644 --- a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java @@ -27,7 +27,7 @@ import static org.junit.Assume.assumeTrue; /** * Tests for query class * - * @author Bjorn Borud + * @author Bjorn Borud */ public class QueryTestCase { |