Search in sources :

Example 6 with HitField

use of com.yahoo.prelude.hitfield.HitField in project vespa by vespa-engine.

the class QuotingSearcher method quoteProperty.

private void quoteProperty(Hit hit, String fieldname, String toQuote, QuoteTable translations) {
    List<FieldPart> l = translate(toQuote, translations, true);
    if (l != null) {
        HitField hf = new HitField(fieldname, toQuote);
        hf.setTokenizedContent(l);
        hit.setField(fieldname, hf);
    }
}
Also used : FieldPart(com.yahoo.prelude.hitfield.FieldPart) ImmutableFieldPart(com.yahoo.prelude.hitfield.ImmutableFieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) HitField(com.yahoo.prelude.hitfield.HitField)

Example 7 with HitField

use of com.yahoo.prelude.hitfield.HitField in project vespa by vespa-engine.

the class TokenFieldIteratorTestCase method testTokenIteratorSet.

@Test
public void testTokenIteratorSet() {
    HitField hf = new HitField("boo", "hei paa deg");
    assertEquals(3, hf.getTokenizedContent().size());
    ListIterator<FieldPart> l = hf.tokenIterator();
    l.next();
    l.next();
    l.set(new StringFieldPart("aap", true));
    l.next();
    assertEquals(false, l.hasNext());
    l.previous();
    l.set(new StringFieldPart("ged", true));
    assertEquals("hei aap ged", hf.getContent());
}
Also used : FieldPart(com.yahoo.prelude.hitfield.FieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) HitField(com.yahoo.prelude.hitfield.HitField) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) Test(org.junit.Test)

Example 8 with HitField

use of com.yahoo.prelude.hitfield.HitField in project vespa by vespa-engine.

the class TokenFieldIteratorTestCase method testTokenIteratorPrevious.

@Test
public void testTokenIteratorPrevious() {
    HitField hf = new HitField("boo", "hei paa");
    ListIterator<?> l = hf.tokenIterator();
    FieldPart p = (FieldPart) l.next();
    assertEquals("hei", p.getContent());
    p = (FieldPart) l.next();
    assertEquals("paa", p.getContent());
    p = (FieldPart) l.previous();
    assertEquals("paa", p.getContent());
    p = (FieldPart) l.previous();
    assertEquals("hei", p.getContent());
}
Also used : FieldPart(com.yahoo.prelude.hitfield.FieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) HitField(com.yahoo.prelude.hitfield.HitField) Test(org.junit.Test)

Example 9 with HitField

use of com.yahoo.prelude.hitfield.HitField in project vespa by vespa-engine.

the class HitFieldTestCase method testHitField.

@Test
public void testHitField() {
    HitField hf = new HitField("boo", "hei paa deg");
    assertEquals(3, hf.getTokenizedContent().size());
    List l = new ArrayList();
    l.add(new StringFieldPart("foo", true));
    l.add(new StringFieldPart(" ", false));
    l.add(new StringFieldPart("bar", true));
    hf.setTokenizedContent(l);
    assertEquals("foo bar", hf.getContent());
    assertEquals("hei paa deg", hf.getRawContent());
}
Also used : HitField(com.yahoo.prelude.hitfield.HitField) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) Test(org.junit.Test)

Example 10 with HitField

use of com.yahoo.prelude.hitfield.HitField in project vespa by vespa-engine.

the class HitFieldTestCase method testCjk.

@Test
public void testCjk() {
    HitField hf = new HitField("boo", "hmm\u001fgr");
    assertEquals(2, hf.getTokenizedContent().size());
    assertEquals("hmmgr", hf.getContent());
    List l = new ArrayList();
    l.add(new StringFieldPart("foo", true));
    l.add(new StringFieldPart("bar", true));
    hf.setTokenizedContent(l);
    assertEquals("foobar", hf.getContent());
}
Also used : HitField(com.yahoo.prelude.hitfield.HitField) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) Test(org.junit.Test)

Aggregations

HitField (com.yahoo.prelude.hitfield.HitField)12 Test (org.junit.Test)9 StringFieldPart (com.yahoo.prelude.hitfield.StringFieldPart)8 FieldPart (com.yahoo.prelude.hitfield.FieldPart)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 ImmutableFieldPart (com.yahoo.prelude.hitfield.ImmutableFieldPart)1 XMLString (com.yahoo.prelude.hitfield.XMLString)1 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)1 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)1 Query (com.yahoo.search.Query)1 Result (com.yahoo.search.Result)1 Searcher (com.yahoo.search.Searcher)1 Hit (com.yahoo.search.result.Hit)1 Relevance (com.yahoo.search.result.Relevance)1 HashMap (java.util.HashMap)1