Search in sources :

Example 1 with IntItem

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);
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) IntItem(com.yahoo.prelude.query.IntItem) OrItem(com.yahoo.prelude.query.OrItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) WordItem(com.yahoo.prelude.query.WordItem) NotItem(com.yahoo.prelude.query.NotItem) IntItem(com.yahoo.prelude.query.IntItem) Test(org.junit.Test)

Example 2 with 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);
}
Also used : IntItem(com.yahoo.prelude.query.IntItem) ByteBuffer(java.nio.ByteBuffer)

Example 3 with IntItem

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());
}
Also used : IntItem(com.yahoo.prelude.query.IntItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) PhraseMatcher(com.yahoo.prelude.querytransform.PhraseMatcher) Test(org.junit.Test)

Example 4 with IntItem

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());
}
Also used : IntItem(com.yahoo.prelude.query.IntItem) Test(org.junit.Test)

Example 5 with IntItem

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);
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) IntItem(com.yahoo.prelude.query.IntItem) OrItem(com.yahoo.prelude.query.OrItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) WordItem(com.yahoo.prelude.query.WordItem) NotItem(com.yahoo.prelude.query.NotItem) IntItem(com.yahoo.prelude.query.IntItem) Test(org.junit.Test)

Aggregations

IntItem (com.yahoo.prelude.query.IntItem)21 Test (org.junit.Test)12 AndItem (com.yahoo.prelude.query.AndItem)11 Item (com.yahoo.prelude.query.Item)9 NonNull (edu.umd.cs.findbugs.annotations.NonNull)7 CompositeItem (com.yahoo.prelude.query.CompositeItem)5 WordItem (com.yahoo.prelude.query.WordItem)5 Query (com.yahoo.search.Query)5 NotItem (com.yahoo.prelude.query.NotItem)4 OrItem (com.yahoo.prelude.query.OrItem)4 PhraseItem (com.yahoo.prelude.query.PhraseItem)4 PhraseSegmentItem (com.yahoo.prelude.query.PhraseSegmentItem)4 PrefixItem (com.yahoo.prelude.query.PrefixItem)4 RankItem (com.yahoo.prelude.query.RankItem)4 SubstringItem (com.yahoo.prelude.query.SubstringItem)4 SuffixItem (com.yahoo.prelude.query.SuffixItem)4 RangeItem (com.yahoo.prelude.query.RangeItem)2 LazyMap (com.yahoo.collections.LazyMap)1 AndSegmentItem (com.yahoo.prelude.query.AndSegmentItem)1 DotProductItem (com.yahoo.prelude.query.DotProductItem)1