Search in sources :

Example 6 with ClientInterface

use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.

the class CharEscapeUtilTest method escape.

@Test
public void escape() {
    StringWriter writer = new StringWriter();
    CharEscapeUtil charEscapeUtil = new CustomCharEscapeUtil(writer, false);
    charEscapeUtil.writeString("/+\"\\", true);
    System.out.println(writer.toString());
    writer = new StringWriter();
    charEscapeUtil = new CustomCharEscapeUtil(writer, true);
    charEscapeUtil.writeString("&/+\"\\", true);
    System.out.println(writer.toString());
    ClientInterface util = (ConfigRestClientUtil) ElasticSearchHelper.getConfigRestClientUtil("demo7.xml");
    Map params = new HashMap();
    params.put("aaa", "_&/+\"\\.");
    System.out.println(util.evalConfigDsl("testesencode", params));
}
Also used : StringWriter(java.io.StringWriter) ConfigRestClientUtil(org.frameworkset.elasticsearch.client.ConfigRestClientUtil) HashMap(java.util.HashMap) ClientInterface(org.frameworkset.elasticsearch.client.ClientInterface) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 7 with ClientInterface

use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.

the class ESTest method testGetmapping.

@Test
public void testGetmapping() {
    SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
    String date = format.format(new Date());
    ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("estrace/ESTracesMapper.xml");
    System.out.println(clientUtil.getIndice("demo-" + date));
    clientUtil.dropIndice("demo-" + date);
}
Also used : ClientInterface(org.frameworkset.elasticsearch.client.ClientInterface) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 8 with ClientInterface

use of org.frameworkset.elasticsearch.client.ClientInterface 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 9 with ClientInterface

use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.

the class ESTest method testConfig.

@Test
public void testConfig() throws ParseException {
    ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("estrace/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;
    }
}
Also used : ESMapResponseHandler(org.frameworkset.elasticsearch.handler.ESMapResponseHandler) FastDateFormat(org.frameworkset.util.FastDateFormat) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ClientInterface(org.frameworkset.elasticsearch.client.ClientInterface) ESStringResponseHandler(org.frameworkset.elasticsearch.handler.ESStringResponseHandler) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 10 with ClientInterface

use of org.frameworkset.elasticsearch.client.ClientInterface in project bboss-elastic by bbossgroups.

the class ESTest method testQueryDocMapping.

@Test
public void testQueryDocMapping() {
    ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil();
    System.out.println(clientUtil.getIndexMapping("trace-*", true));
    final List<IndexField> fields = clientUtil.getIndexMappingFields("trace-*", "trace");
    System.out.println(fields.size());
}
Also used : ClientInterface(org.frameworkset.elasticsearch.client.ClientInterface) IndexField(org.frameworkset.elasticsearch.entity.IndexField) Test(org.junit.Test)

Aggregations

ClientInterface (org.frameworkset.elasticsearch.client.ClientInterface)23 Test (org.junit.Test)21 SimpleDateFormat (java.text.SimpleDateFormat)9 DateFormat (java.text.DateFormat)3 ESMapResponseHandler (org.frameworkset.elasticsearch.handler.ESMapResponseHandler)3 ESStringResponseHandler (org.frameworkset.elasticsearch.handler.ESStringResponseHandler)3 FastDateFormat (org.frameworkset.util.FastDateFormat)3 File (java.io.File)2 DefaultApplicationContext (org.frameworkset.spi.DefaultApplicationContext)2 StringWriter (java.io.StringWriter)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SocketConfig (org.apache.http.config.SocketConfig)1 ConfigRestClientUtil (org.frameworkset.elasticsearch.client.ConfigRestClientUtil)1 IndexField (org.frameworkset.elasticsearch.entity.IndexField)1