use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.
the class ESTest method testSearh.
@Test
public void testSearh() throws ParseException {
ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("org/frameworkset/elasticsearch/ESTracesMapper.xml");
TraceExtraCriteria traceExtraCriteria = new TraceExtraCriteria();
traceExtraCriteria.setApplication("testweb1");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
traceExtraCriteria.setStartTime(dateFormat.parse("2017-09-02 00:00:00").getTime());
traceExtraCriteria.setEndTime(dateFormat.parse("2017-09-10 00:00:00").getTime());
String data = clientUtil.executeRequest("trace-*/_search", "queryPeriodsTopN", traceExtraCriteria, new ESStringResponseHandler());
System.out.println("------------------------------");
System.out.println(data);
System.out.println("------------------------------");
Map<String, Object> response = clientUtil.executeRequest("trace-*/_search", "queryPeriodsTopN", traceExtraCriteria, new ESMapResponseHandler());
if (response.containsKey("error")) {
return;
}
}
use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.
the class ESTest method testSearhHits.
@Test
public void testSearhHits() throws ParseException {
ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("org/frameworkset/elasticsearch/ESTracesMapper.xml");
TraceExtraCriteria traceExtraCriteria = new TraceExtraCriteria();
traceExtraCriteria.setApplication("testweb1");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
traceExtraCriteria.setStartTime(dateFormat.parse("2017-09-02 00:00:00").getTime());
traceExtraCriteria.setEndTime(dateFormat.parse("2017-09-10 00:00:00").getTime());
String data = clientUtil.executeRequest("trace-*/_search", "queryPeriodsTopN", traceExtraCriteria, new ESStringResponseHandler());
System.out.println("------------------------------");
System.out.println(data);
System.out.println("------------------------------");
Map<String, Object> response = clientUtil.executeRequest("trace-*/_search", "queryPeriodsTopN", traceExtraCriteria, new ESMapResponseHandler());
if (response.containsKey("error")) {
return;
}
}
use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.
the class ESTest method testTempate.
@Test
public void testTempate() throws ParseException {
ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("estrace/ESTemplate.xml");
// 创建模板
String response = // 模板名称
clientUtil.createTempate(// 模板名称
"demotemplate_1", // 模板对应的脚本名称,在estrace/ESTemplate.xml中配置
"demoTemplate");
System.out.println("createTempate-------------------------");
System.out.println(response);
// 获取模板
/**
* 指定模板
* /_template/demoTemplate_1
* /_template/demoTemplate*
* 所有模板 /_template
*/
String template = clientUtil.executeHttp("/_template/demotemplate_1", ClientUtil.HTTP_GET);
System.out.println("HTTP_GET-------------------------");
System.out.println(template);
// 删除模板
template = clientUtil.executeHttp("/_template/demotemplate_1", ClientUtil.HTTP_DELETE);
System.out.println("HTTP_DELETE-------------------------");
System.out.println(template);
template = clientUtil.executeHttp("/_template/demotemplate_1", ClientUtil.HTTP_GET);
System.out.println("HTTP_GET after delete-------------------------");
System.out.println(template);
}
use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.
the class ESTest method testCreateDemoMapping.
@Test
public void testCreateDemoMapping() {
ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("estrace/ESTracesMapper.xml");
try {
// 获取索引表结构
System.out.println(clientUtil.getIndice("demo"));
// 删除索引表结构
System.out.println(clientUtil.dropIndice("demo"));
} catch (ElasticSearchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 创建索引表结构
System.out.println(clientUtil.createIndiceMapping("demo", "createDemoIndice"));
System.out.println(clientUtil.getIndice("demo"));
System.out.println(clientUtil.getIndice("demo"));
System.out.println(clientUtil.getIndice("demo"));
}
use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.
the class ESTest method testAddDateDocumentByTemplate.
@Test
public void testAddDateDocumentByTemplate() throws ParseException {
testGetmapping();
SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
String date = format.format(new Date());
ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("estrace/ESTracesMapper.xml");
Demo demo = new Demo();
demo.setDemoId(5l);
demo.setAgentStarttime(new Date());
demo.setApplicationName("blackcatdemo");
demo.setContentbody("this is content body");
// 创建模板
String response = // 索引表
clientUtil.addDateDocument(// 索引表
"demo", // 索引类型
"demo", // 创建文档对应的脚本名称,在estrace/ESTracesMapper.xml中配置
"createDemoDocument", demo);
System.out.println("addDateDocument-------------------------");
System.out.println(response);
response = // 索引表
clientUtil.getDocument(// 索引表
"demo-" + date, // 索引类型
"demo", "5");
System.out.println("getDocument-------------------------");
System.out.println(response);
demo = // 索引表
clientUtil.getDocument(// 索引表
"demo-" + date, // 索引类型
"demo", // 创建文档对应的脚本名称,在estrace/ESTracesMapper.xml中配置
"5", Demo.class);
}
Aggregations