Search in sources :

Example 1 with DoubleBucketId

use of com.yahoo.search.grouping.result.DoubleBucketId in project vespa by vespa-engine.

the class JsonRendererTestCase method testGroupingWithBucket.

@Test
public void testGroupingWithBucket() throws InterruptedException, ExecutionException, IOException {
    String expected = "{\n" + "    \"root\": {\n" + "        \"children\": [\n" + "            {\n" + "                \"children\": [\n" + "                    {\n" + "                        \"children\": [\n" + "                            {\n" + "                                \"fields\": {\n" + "                                    \"something()\": 7\n" + "                                },\n" + "                                \"limits\": {\n" + "                                    \"from\": \"1.0\",\n" + "                                    \"to\": \"2.0\"\n" + "                                },\n" + "                                \"id\": \"group:double_bucket:1.0:2.0\",\n" + "                                \"relevance\": 1.0\n" + "                            }\n" + "                        ],\n" + "                        \"id\": \"grouplist:customer\",\n" + "                        \"label\": \"customer\",\n" + "                        \"relevance\": 1.0\n" + "                    }\n" + "                ],\n" + "                \"continuation\": {\n" + "                    \"this\": \"AAAA\"\n" + "                },\n" + "                \"id\": \"group:root:0\",\n" + "                \"relevance\": 1.0\n" + "            }\n" + "        ],\n" + "        \"fields\": {\n" + "            \"totalCount\": 1\n" + "        },\n" + "        \"id\": \"toplevel\",\n" + "        \"relevance\": 1.0\n" + "    }\n" + "}\n";
    Result r = newEmptyResult();
    RootGroup rg = new RootGroup(0, new Continuation() {

        @Override
        public String toString() {
            return "AAAA";
        }
    });
    GroupList gl = new GroupList("customer");
    Group g = new Group(new DoubleBucketId(1.0, 2.0), new Relevance(1.0));
    g.setField("something()", Integer.valueOf(7));
    gl.add(g);
    rg.add(gl);
    r.hits().add(rg);
    r.setTotalHitCount(1L);
    String summary = render(r);
    assertEqualJson(expected, summary);
}
Also used : Relevance(com.yahoo.search.result.Relevance) Group(com.yahoo.search.grouping.result.Group) RootGroup(com.yahoo.search.grouping.result.RootGroup) HitGroup(com.yahoo.search.result.HitGroup) Continuation(com.yahoo.search.grouping.Continuation) GroupList(com.yahoo.search.grouping.result.GroupList) JSONString(com.yahoo.prelude.hitfield.JSONString) RootGroup(com.yahoo.search.grouping.result.RootGroup) DoubleBucketId(com.yahoo.search.grouping.result.DoubleBucketId) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

JSONString (com.yahoo.prelude.hitfield.JSONString)1 Result (com.yahoo.search.Result)1 Continuation (com.yahoo.search.grouping.Continuation)1 DoubleBucketId (com.yahoo.search.grouping.result.DoubleBucketId)1 Group (com.yahoo.search.grouping.result.Group)1 GroupList (com.yahoo.search.grouping.result.GroupList)1 RootGroup (com.yahoo.search.grouping.result.RootGroup)1 HitGroup (com.yahoo.search.result.HitGroup)1 Relevance (com.yahoo.search.result.Relevance)1 Test (org.junit.Test)1