Examples of templateSource()


Examples of org.elasticsearch.action.search.SearchRequest.templateSource()

        // get the content, and put it in the body
        // add content/source as template if template flag is set
        boolean isTemplateRequest = request.path().endsWith("/template");
        if (request.hasContent()) {
            if (isTemplateRequest) {
                searchRequest.templateSource(request.content(), request.contentUnsafe());
            } else {
                searchRequest.source(request.content(), request.contentUnsafe());
            }
        } else {
            String source = request.param("source");
View Full Code Here

Examples of org.elasticsearch.action.search.SearchRequest.templateSource()

            }
        } else {
            String source = request.param("source");
            if (source != null) {
                if (isTemplateRequest) {
                    searchRequest.templateSource(source);
                } else {
                    searchRequest.source(source);
                }
            }
        }
View Full Code Here

Examples of org.elasticsearch.action.search.SearchRequest.templateSource()

        SearchRequest searchRequest = new SearchRequest();
        searchRequest.indices("_all");

        String query = "{ \"template\" : { \"query\": {\"match_{{template}}\": {} } }, \"params\" : { \"template\":\"all\" } }";
        BytesReference bytesRef = new BytesArray(query);
        searchRequest.templateSource(bytesRef, false);

        SearchResponse searchResponse = client().search(searchRequest).get();
        assertHitCount(searchResponse, 2);
    }
View Full Code Here

Examples of org.elasticsearch.action.search.SearchRequest.templateSource()

        SearchRequest searchRequest = new SearchRequest();
        searchRequest.indices("_all");
        try {
            String query = "{ \"template\" : { \"query\": {\"match_all\": {}}, \"size\" : \"{{my_size}}\"  } }";
            BytesReference bytesRef = new BytesArray(query);
            searchRequest.templateSource(bytesRef, false);
            client().search(searchRequest).get();
            fail("expected exception");
        } catch (Throwable ex) {
            // expected - no params
        }
View Full Code Here

Examples of org.elasticsearch.action.search.SearchRequest.templateSource()

        } catch (Throwable ex) {
            // expected - no params
        }
        String query = "{ \"template\" : { \"query\": {\"match_all\": {}}, \"size\" : \"{{my_size}}\"  }, \"params\" : { \"my_size\": 1 } }";
        BytesReference bytesRef = new BytesArray(query);
        searchRequest.templateSource(bytesRef, false);

        SearchResponse searchResponse = client().search(searchRequest).get();
        assertThat(searchResponse.getHits().hits().length, equalTo(1));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.