Search in sources :

Example 11 with HitField

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

the class HitFieldTestCase method testEmptyField.

@Test
public void testEmptyField() {
    HitField hf = new HitField("boo", "");
    assertEquals(0, hf.getTokenizedContent().size());
}
Also used : HitField(com.yahoo.prelude.hitfield.HitField) Test(org.junit.Test)

Example 12 with HitField

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

the class QuotingSearcherTestCase method testFieldQuotingWithNoisyStrings.

public void testFieldQuotingWithNoisyStrings() {
    Map<Searcher, Searcher> chained = new HashMap<>();
    Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/" + "searcher/test/testquoting.cfg");
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    chained.put(s, docsource);
    Query q = new Query("?query=a");
    Result r = new Result(q);
    Hit hit = new FastHit();
    hit.setId("http://abc.html");
    hit.setRelevance(new Relevance(1));
    hit.setField("title", new HitField("title", "&smith &jo& nes"));
    r.hits().add(hit);
    docsource.addResultSet(q, r);
    Result check = doSearch(s, q, 0, 10, chained);
    assertEquals("&amp;smith &amp;jo&amp; nes", check.hits().get(0).getField("title").toString());
    assertTrue(check.hits().get(0).fields().containsKey("title"));
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) QuotingSearcher(com.yahoo.prelude.searcher.QuotingSearcher) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) HitField(com.yahoo.prelude.hitfield.HitField) DocumentSourceSearcher(com.yahoo.prelude.searcher.DocumentSourceSearcher) Result(com.yahoo.search.Result)

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