Package org.elasticsearch.action.view

Examples of org.elasticsearch.action.view.ViewRequest


        );
    }

    @Test
    public void testDefaultView() throws Exception {
        ViewResponse response = esSetup.client().execute(ViewAction.INSTANCE, new ViewRequest("catalog", "product", "1")).get();
        assertEquals("Rendering the document #1 in version 1 of type product from index catalog", new String(response.content(), "UTF-8"));
    }
View Full Code Here


        assertEquals("Rendering the document #1 in version 1 of type product from index catalog", new String(response.content(), "UTF-8"));
    }

    @Test
    public void testFullView() throws Exception {
        ViewResponse response = esSetup.client().execute(ViewAction.INSTANCE, new ViewRequest("catalog", "product", "2").format("full")).get();
        assertEquals("<div id=\"product-2\"><h2>Detail of 1952 ALPINE RENAULT 1300</h2><p>Year: 1952, price: 98.58€</p><p>Turnable front wheels; steering function; detailed interior; detailed engine; opening hood; opening trunk; opening doors; and detailed chassis.</p><p>© Copyright Renault</p></div>", new String(response.content(), "UTF-8"));
    }
View Full Code Here

        assertEquals("<div id=\"product-2\"><h2>Detail of 1952 ALPINE RENAULT 1300</h2><p>Year: 1952, price: 98.58€</p><p>Turnable front wheels; steering function; detailed interior; detailed engine; opening hood; opening trunk; opening doors; and detailed chassis.</p><p>© Copyright Renault</p></div>", new String(response.content(), "UTF-8"));
    }

    @Test
    public void testBinaryView() throws Exception {
        ViewResponse response = esSetup.client().execute(ViewAction.INSTANCE, new ViewRequest("catalog", "product", "1").format("logo")).get();
        assertNotNull(response.content());
        assertEquals(0, response.content().length);

        response = esSetup.client().execute(ViewAction.INSTANCE, new ViewRequest("catalog", "product", "2").format("logo")).get();
        assertNotNull(response.content());
        assertEquals(61752, response.content().length);
    }
View Full Code Here

    }

    @Test
    public void testUndefinedView() throws Exception {
        try {
            ViewResponse response = esSetup.client().execute(ViewAction.INSTANCE, new ViewRequest("catalog", "product", "1").format("undefined")).get();
            fail("Exception expected!");
        } catch (Exception e) {
            assertEquals("org.elasticsearch.view.exception.ElasticSearchViewNotFoundException: No view [undefined] found for document type [product]", e.getMessage());
        }
    }
View Full Code Here

                        "        }\n" +
                        "    }\n" +
                        "}")
        );

        ViewResponse response = esSetup.client().execute(ViewAction.INSTANCE, new ViewRequest("catalog", "list-of-products-by-size", "1:10")).get();
        assertEquals(fromClassPath("org/elasticsearch/test/integration/views/config/views/list-of-products.html").toString(), new String(response.content(), "UTF-8"));
    }
View Full Code Here

                                "        }\n" +
                                "    }\n" +
                                "}")
        );

        ViewResponse response = esSetup.client().execute(ViewAction.INSTANCE, new ViewRequest("web", "pages", "home")).get();
        assertEquals(fromClassPath("org/elasticsearch/test/integration/views/config/views/list-of-products-with-brands.html").toString(), new String(response.content(), "UTF-8"));
    }
View Full Code Here

        controller.registerHandler(GET, "/_view/{index}/{type}/{id}", this);
        controller.registerHandler(GET, "/_view/{index}/{type}/{id}/{format}", this);
    }

    public void handleRequest(final RestRequest request, final RestChannel channel) {
        ViewRequest viewRequest = new ViewRequest(request.param("index"), request.param("type"), request.param("id"));
        if (request.hasParam("format")) {
            viewRequest.format(request.param("format"));
        }

        // we just send a response, no need to fork
        viewRequest.listenerThreaded(false);
        // we don't spawn, then fork if local
        viewRequest.operationThreaded(true);

        client.execute(ViewAction.INSTANCE, viewRequest, new ActionListener<ViewResponse>() {

            public void onResponse(ViewResponse response) {
                try {
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.view.ViewRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.