Search in sources :

Example 46 with WordItem

use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.

the class ItemEncodingTestCase method testAndItemEncoding.

@Test
public void testAndItemEncoding() {
    WordItem a = new WordItem("a");
    WordItem b = new WordItem("b");
    AndItem and = new AndItem();
    and.addItem(a);
    and.addItem(b);
    ByteBuffer buffer = ByteBuffer.allocate(128);
    int count = and.encode(buffer);
    buffer.flip();
    assertEquals("Serialization count", 3, count);
    assertType(buffer, 1, 0);
    assertEquals("And arity", 2, buffer.get());
    assertWord(buffer, "a");
    assertWord(buffer, "b");
}
Also used : AndItem(com.yahoo.prelude.query.AndItem) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 47 with WordItem

use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.

the class ItemEncodingTestCase method testWordItemEncoding.

@Test
public void testWordItemEncoding() {
    WordItem word = new WordItem("test");
    word.setWeight(150);
    ByteBuffer buffer = ByteBuffer.allocate(128);
    int count = word.encode(buffer);
    buffer.flip();
    assertEquals("Serialization count", 1, count);
    assertType(buffer, 4, 1);
    assertWeight(buffer, 150);
    assertEquals("Index length", 0, buffer.get());
    assertEquals("Word length", 4, buffer.get());
    assertEquals("Word length", 4, buffer.remaining());
    assertEquals('t', buffer.get());
    assertEquals('e', buffer.get());
    assertEquals('s', buffer.get());
    assertEquals('t', buffer.get());
}
Also used : MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 48 with WordItem

use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.

the class ItemEncodingTestCase method testNearItemEncoding.

@Test
public void testNearItemEncoding() {
    WordItem a = new WordItem("a");
    WordItem b = new WordItem("b");
    NearItem near = new NearItem(7);
    near.addItem(a);
    near.addItem(b);
    ByteBuffer buffer = ByteBuffer.allocate(128);
    int count = near.encode(buffer);
    buffer.flip();
    assertEquals("Serialization count", 3, count);
    assertType(buffer, 11, 0);
    assertEquals("Near arity", 2, buffer.get());
    assertEquals("Limit", 7, buffer.get());
    assertWord(buffer, "a");
    assertWord(buffer, "b");
}
Also used : MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) ONearItem(com.yahoo.prelude.query.ONearItem) NearItem(com.yahoo.prelude.query.NearItem) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 49 with WordItem

use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.

the class ItemEncodingTestCase method testFilterWordItemEncoding.

@Test
public void testFilterWordItemEncoding() {
    WordItem word = new WordItem("test");
    word.setFilter(true);
    ByteBuffer buffer = ByteBuffer.allocate(128);
    int count = word.encode(buffer);
    buffer.flip();
    assertEquals("Serialization count", 1, count);
    assertType(buffer, 4, 4);
    assertEquals(0x08, buffer.get());
    assertEquals("Index length", 0, buffer.get());
    assertEquals("Word length", 4, buffer.get());
    assertEquals("Word length", 4, buffer.remaining());
    assertEquals('t', buffer.get());
    assertEquals('e', buffer.get());
    assertEquals('s', buffer.get());
    assertEquals('t', buffer.get());
}
Also used : MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 50 with WordItem

use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.

the class ItemEncodingTestCase method testEquivItemEncoding.

@Test
public void testEquivItemEncoding() {
    WordItem a = new WordItem("a");
    WordItem b = new WordItem("b");
    EquivItem equiv = new EquivItem();
    equiv.addItem(a);
    equiv.addItem(b);
    ByteBuffer buffer = ByteBuffer.allocate(128);
    int count = equiv.encode(buffer);
    buffer.flip();
    assertEquals("Serialization count", 3, count);
    assertType(buffer, 14, 0);
    assertEquals("Equiv arity", 2, buffer.get());
    assertWord(buffer, "a");
    assertWord(buffer, "b");
}
Also used : EquivItem(com.yahoo.prelude.query.EquivItem) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

WordItem (com.yahoo.prelude.query.WordItem)93 Test (org.junit.Test)76 AndItem (com.yahoo.prelude.query.AndItem)45 PhraseItem (com.yahoo.prelude.query.PhraseItem)31 Query (com.yahoo.search.Query)25 PhraseSegmentItem (com.yahoo.prelude.query.PhraseSegmentItem)20 CompositeItem (com.yahoo.prelude.query.CompositeItem)18 Item (com.yahoo.prelude.query.Item)17 MarkerWordItem (com.yahoo.prelude.query.MarkerWordItem)16 NotItem (com.yahoo.prelude.query.NotItem)16 OrItem (com.yahoo.prelude.query.OrItem)13 ByteBuffer (java.nio.ByteBuffer)11 PrefixItem (com.yahoo.prelude.query.PrefixItem)10 SubstringItem (com.yahoo.prelude.query.SubstringItem)10 SuffixItem (com.yahoo.prelude.query.SuffixItem)10 Execution (com.yahoo.search.searchchain.Execution)10 RankItem (com.yahoo.prelude.query.RankItem)9 PhraseMatcher (com.yahoo.prelude.querytransform.PhraseMatcher)9 IntItem (com.yahoo.prelude.query.IntItem)8 WeakAndItem (com.yahoo.prelude.query.WeakAndItem)7