Search in sources :

Example 1 with DefaultApplicationContext

use of org.frameworkset.spi.DefaultApplicationContext in project bboss-elastic by bbossgroups.

the class ESTest method querey.

@Test
public void querey() throws Exception {
    DefaultApplicationContext context = DefaultApplicationContext.getApplicationContext("conf/elasticsearch.xml");
    ElasticSearch elasticSearchSink = context.getTBeanObject("elasticSearch", ElasticSearch.class);
    // ElasticSearch restelasticSearchSink = context.getTBeanObject("restelasticSearch", ElasticSearch.class);
    ClientInterface clientUtil = elasticSearchSink.getRestClientUtil();
    String entiry = "{\"query\" : {\"term\" : { \"rpc\" : \"content.page\" }}}";
    String response = (String) clientUtil.executeRequest("trace-*/_search", entiry);
    System.out.println(response);
}
Also used : DefaultApplicationContext(org.frameworkset.spi.DefaultApplicationContext) ClientInterface(org.frameworkset.elasticsearch.client.ClientInterface) Test(org.junit.Test)

Example 2 with DefaultApplicationContext

use of org.frameworkset.spi.DefaultApplicationContext in project bboss-elastic by bbossgroups.

the class ESTest method test.

@Test
public void test() throws Exception {
    DefaultApplicationContext context = DefaultApplicationContext.getApplicationContext("conf/elasticsearch.xml");
    ElasticSearch elasticSearchSink = context.getTBeanObject("elasticSearch", ElasticSearch.class);
    // ElasticSearch restelasticSearchSink = context.getTBeanObject("restelasticSearch", ElasticSearch.class);
    ClientInterface clientUtil = elasticSearchSink.getRestClientUtil();
    String entity = "{" + "\"aggs\": {" + "\"top_tags\": {" + "\"terms\": {" + "\"field\": \"rpc.keyword\"," + "\"size\": 30" + "}," + "\"aggs\": {" + "\"top_sales_hits\": {" + "\"top_hits\": {" + "\"sort\": [" + "{" + "\"collectorAcceptTime\": {" + "\"order\": \"desc\"" + "}" + "}" + "]," + "\"_source\": {" + "\"includes\": [ \"collectorAcceptTime\", \"rpc\" ]" + "}," + "\"size\" : 1" + "}" + "}" + "}" + "}" + "}" + "}";
    String response = (String) clientUtil.executeRequest("trace-*/_search?size=0", entity);
    System.out.println(response);
}
Also used : DefaultApplicationContext(org.frameworkset.spi.DefaultApplicationContext) ClientInterface(org.frameworkset.elasticsearch.client.ClientInterface) Test(org.junit.Test)

Aggregations

ClientInterface (org.frameworkset.elasticsearch.client.ClientInterface)2 DefaultApplicationContext (org.frameworkset.spi.DefaultApplicationContext)2 Test (org.junit.Test)2