Search in sources :

Example 6 with WordAlternativesItem

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

the class NormalizingSearcherTestCase method testLiteralBoost.

@Test
public void testLiteralBoost() {
    Query query = new Query("/search?query=nop&search=cluster1&restrict=type1");
    List<WordAlternativesItem.Alternative> terms = new ArrayList<>();
    Substring origin = new Substring(0, 5, "h\u00F4tels");
    terms.add(new WordAlternativesItem.Alternative("h\u00F4tels", 1.0d));
    terms.add(new WordAlternativesItem.Alternative("h\u00F4tel", 0.7d));
    query.getModel().getQueryTree().setRoot(new WordAlternativesItem("default", true, origin, terms));
    createExecution().search(query);
    WordAlternativesItem w = (WordAlternativesItem) query.getModel().getQueryTree().getRoot();
    assertEquals(4, w.getAlternatives().size());
    boolean foundHotel = false;
    for (WordAlternativesItem.Alternative a : w.getAlternatives()) {
        if ("hotel".equals(a.word)) {
            foundHotel = true;
            assertEquals(.7d * .7d, a.exactness, 1e-15);
        }
    }
    assertTrue("Did not find the expected normalized form \"hotel\".", foundHotel);
}
Also used : Substring(com.yahoo.prelude.query.Substring) Query(com.yahoo.search.Query) ArrayList(java.util.ArrayList) WordAlternativesItem(com.yahoo.prelude.query.WordAlternativesItem) Test(org.junit.Test)

Aggregations

WordAlternativesItem (com.yahoo.prelude.query.WordAlternativesItem)6 Test (org.junit.Test)5 AndItem (com.yahoo.prelude.query.AndItem)3 ExactStringItem (com.yahoo.prelude.query.ExactStringItem)3 IndexedItem (com.yahoo.prelude.query.IndexedItem)3 Item (com.yahoo.prelude.query.Item)3 PhraseItem (com.yahoo.prelude.query.PhraseItem)3 PrefixItem (com.yahoo.prelude.query.PrefixItem)3 RegExpItem (com.yahoo.prelude.query.RegExpItem)3 Substring (com.yahoo.prelude.query.Substring)3 SubstringItem (com.yahoo.prelude.query.SubstringItem)3 SuffixItem (com.yahoo.prelude.query.SuffixItem)3 WeakAndItem (com.yahoo.prelude.query.WeakAndItem)3 WordItem (com.yahoo.prelude.query.WordItem)3 QueryTree (com.yahoo.search.query.QueryTree)3 ArrayList (java.util.ArrayList)3 Query (com.yahoo.search.Query)2 Chain (com.yahoo.component.chain.Chain)1 Alternative (com.yahoo.prelude.query.WordAlternativesItem.Alternative)1 Result (com.yahoo.search.Result)1