use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class ParseTestCase method testDouble.
@Test
public void testDouble() {
Item number = tester.assertParsed("123456789.987654321", "123456789.987654321", Query.Type.ALL);
assertTrue(number instanceof IntItem);
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class RangeItemTestCase method verifyRange.
private void verifyRange(RangeItem range, int limit, boolean isFromQuery) {
assertEquals(5, range.getFrom());
assertEquals(7, range.getTo());
assertEquals(limit, range.getHitLimit());
assertEquals("a", range.getIndexName());
if (range.getHitLimit() != 0) {
assertEquals("[5;7;9]", range.getNumber());
} else {
assertEquals("[5;7]", range.getNumber());
}
assertEquals(isFromQuery, range.isFromQuery());
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = range.encode(buffer);
ByteBuffer buffer2 = ByteBuffer.allocate(128);
int count2 = new IntItem(range.getNumber(), range.getIndexName(), range.isFromQuery()).encode(buffer2);
assertEquals(buffer, buffer2);
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class PhraseMatcherTestCase method testPhraseMatchingWithNumber.
@Test
public void testPhraseMatchingWithNumber() {
PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
AndItem and = new AndItem();
and.addItem(new WordItem("noisebefore"));
and.addItem(new WordItem("this"));
and.addItem(new WordItem("is"));
and.addItem(new IntItem("3"));
and.addItem(new WordItem("tests"));
and.addItem(new WordItem("noiseafter"));
List<?> matches = matcher.matchPhrases(and);
assertNotNull(matches);
assertEquals(1, matches.size());
PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
assertEquals(4, match.getLength());
assertEquals("", match.getData());
assertEquals(and, match.getOwner());
assertEquals(1, match.getStartIndex());
PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
assertEquals(new WordItem("this"), i.next());
assertEquals(null, i.getReplace());
assertEquals(new WordItem("is"), i.next());
assertEquals(null, i.getReplace());
assertEquals(new IntItem("3"), i.next());
assertEquals(null, i.getReplace());
assertEquals(new WordItem("tests"), i.next());
assertEquals(null, i.getReplace());
assertFalse(i.hasNext());
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class ParseTestCase method testGreaterNumericWithIndex.
@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());
}
use of com.yahoo.prelude.query.IntItem in project vespa by vespa-engine.
the class ParseTestCase method testDecimal.
@Test
public void testDecimal() {
Item root = tester.assertParsed("2.2", "2.2", Query.Type.ALL);
assertTrue(root instanceof IntItem);
tester.assertParsed("normal:2.2", "normal:2.2", Query.Type.ALL);
}
Aggregations