use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class RangeQueryOptimizerTestCase method testNoRangeOptimizingWhenAttributesAreIncompatible.
@Test
public void testNoRangeOptimizingWhenAttributesAreIncompatible() {
Query query = new Query();
AndItem root = new AndItem();
query.getModel().getQueryTree().setRoot(root);
Item intItem1 = new IntItem(">" + 15, "s");
intItem1.setFilter(true);
intItem1.setRanked(false);
intItem1.setWeight(500);
root.addItem(intItem1);
Item intItem2 = new IntItem("<" + 30, "s");
// Disagrees with item1
intItem2.setFilter(false);
intItem2.setRanked(false);
intItem2.setWeight(500);
root.addItem(intItem2);
assertOptimized("Not optimized", "AND |s:<15;]!500 s:[;30>!500", query);
IntItem transformedIntItem1 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(0);
assertTrue("Filter was carried over", transformedIntItem1.isFilter());
assertFalse("Ranked was carried over", transformedIntItem1.isRanked());
assertEquals("Weight was carried over", 500, transformedIntItem1.getWeight());
IntItem transformedIntItem2 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(1);
assertFalse("Filter was carried over", transformedIntItem2.isFilter());
assertFalse("Ranked was carried over", transformedIntItem2.isRanked());
assertEquals("Weight was carried over", 500, transformedIntItem2.getWeight());
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class RangeQueryOptimizerTestCase method testDifferentCompatibleRangesPerFieldAreOptimizedSeparately.
@Test
public void testDifferentCompatibleRangesPerFieldAreOptimizedSeparately() {
Query query = new Query();
AndItem root = new AndItem();
query.getModel().getQueryTree().setRoot(root);
// Two internally compatible items
Item intItem1 = new IntItem(">" + 15, "s");
intItem1.setRanked(false);
root.addItem(intItem1);
Item intItem2 = new IntItem("<" + 30, "s");
intItem2.setRanked(false);
root.addItem(intItem2);
// Two other internally compatible items incompatible with the above
Item intItem3 = new IntItem(">" + 100, "s");
root.addItem(intItem3);
Item intItem4 = new IntItem("<" + 150, "s");
root.addItem(intItem4);
assertOptimized("Optimized", "AND s:<15;30> s:<100;150>", query);
IntItem transformedIntItem1 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(0);
assertFalse("Ranked was carried over", transformedIntItem1.isRanked());
IntItem transformedIntItem2 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(1);
assertTrue("Ranked was carried over", transformedIntItem2.isRanked());
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class ParseTestCase method testZipCodeShortcutWeb.
@Test
public void testZipCodeShortcutWeb() {
tester.assertParsed("12345", "12345", Query.Type.WEB);
IntItem root = (IntItem) tester.assertParsed("00012!150", "00012!", Query.Type.WEB);
assertEquals('!', root.getOrigin().charAfter(0));
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class ParseTestCase method testLong.
@Test
public void testLong() {
Item number = tester.assertParsed("3000000000000", "3000000000000", Query.Type.ALL);
assertTrue(number instanceof IntItem);
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class IntItemTestCase method testEquals.
@Test
public void testEquals() {
Query q1 = new Query("/?query=123%20456%20789");
Query q2 = new Query("/?query=123%20456");
AndItem andItem = (AndItem) q2.getModel().getQueryTree().getRoot();
andItem.addItem(new IntItem(789l, ""));
assertEquals(q1, q2);
}
Aggregations