Search in sources :

Example 1 with Freshness

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

the class Ranking method setFreshness.

/**
 * Set the freshness search parameters for this query
 */
public void setFreshness(String dateTime) {
    try {
        Freshness freshness = new Freshness(dateTime);
        setFreshness(freshness);
    } catch (NumberFormatException e) {
        parent.errors().add(ErrorMessage.createInvalidQueryParameter("Datetime reference could not be converted from '" + dateTime + "' to long"));
    }
}
Also used : Freshness(com.yahoo.prelude.Freshness)

Example 2 with Freshness

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

the class QueryTestCase method testEncodeQueryPacketWithManyFeatures.

/**
 * This test will tell you if you have screwed up the binary encoding, but it won't tell you how
 */
@Test
public void testEncodeQueryPacketWithManyFeatures() {
    Query query = new Query("/?query=chain" + "&ranking.features.query(foo)=30.3&ranking.features.query(bar)=0" + "&ranking.properties.property.p1=v1&ranking.properties.property.p2=v2" + "&pos.ll=S22.4532;W123.9887&pos.radius=3&pos.attribute=place&ranking.freshness=37" + "&model.searchPath=7/3");
    query.getRanking().setFreshness(new Freshness("123456"));
    query.getRanking().setSorting("+field1 -field2");
    query.getRanking().setProfile("two");
    Highlight highlight = new Highlight();
    highlight.addHighlightTerm("field1", "term1");
    highlight.addHighlightTerm("field1", "term2");
    query.getPresentation().setHighlight(highlight);
    query.prepare();
    QueryPacket packet = QueryPacket.create(query);
    byte[] encoded = packetToBytes(packet);
    byte[] correctBuffer = new byte[] { 0, 0, 1, 23, 0, 0, 0, -38, 0, 0, 0, 0, 0, 16, 0, -122, 0, 10, ignored, ignored, ignored, ignored, 0, 0, 0x40, 0x03, 3, 't', 'w', 'o', 0, 0, 0, 3, 0, 0, 0, 4, 'r', 'a', 'n', 'k', 0, 0, 0, 5, 0, 0, 0, 11, 'p', 'r', 'o', 'p', 'e', 'r', 't', 'y', 46, 'p', '2', 0, 0, 0, 2, 'v', '2', 0, 0, 0, 11, 'p', 'r', 'o', 'p', 'e', 'r', 't', 'y', 46, 'p', '1', 0, 0, 0, 2, 'v', '1', 0, 0, 0, 3, 'f', 'o', 'o', 0, 0, 0, 4, '3', '0', 46, '3', 0, 0, 0, 3, 'b', 'a', 'r', 0, 0, 0, 1, '0', 0, 0, 0, 9, 'v', 'e', 's', 'p', 'a', 46, 'n', 'o', 'w', 0, 0, 0, 6, '1', '2', '3', '4', '5', '6', 0, 0, 0, 14, 'h', 'i', 'g', 'h', 'l', 'i', 'g', 'h', 't', 't', 'e', 'r', 'm', 's', 0, 0, 0, 3, 0, 0, 0, 6, 'f', 'i', 'e', 'l', 'd', '1', 0, 0, 0, 1, '2', 0, 0, 0, 6, 'f', 'i', 'e', 'l', 'd', '1', 0, 0, 0, 5, 't', 'e', 'r', 'm', '1', 0, 0, 0, 6, 'f', 'i', 'e', 'l', 'd', '1', 0, 0, 0, 5, 't', 'e', 'r', 'm', '2', 0, 0, 0, 5, 'm', 'o', 'd', 'e', 'l', 0, 0, 0, 1, 0, 0, 0, 10, 's', 'e', 'a', 'r', 'c', 'h', 'p', 'a', 't', 'h', 0, 0, 0, 3, '7', 47, '3', 0, 0, 0, 15, 43, 'f', 'i', 'e', 'l', 'd', '1', 32, 45, 'f', 'i', 'e', 'l', 'd', '2', 0, 0, 0, 1, 0, 0, 0, 9, 68, 1, 0, 5, 'c', 'h', 'a', 'i', 'n' };
    assertEqualArrays(correctBuffer, encoded);
}
Also used : Highlight(com.yahoo.prelude.query.Highlight) Query(com.yahoo.search.Query) Freshness(com.yahoo.prelude.Freshness) QueryPacket(com.yahoo.fs4.QueryPacket) Test(org.junit.Test)

Aggregations

Freshness (com.yahoo.prelude.Freshness)2 QueryPacket (com.yahoo.fs4.QueryPacket)1 Highlight (com.yahoo.prelude.query.Highlight)1 Query (com.yahoo.search.Query)1 Test (org.junit.Test)1