RestClientUtil和ConfigRestClientUtil区别说明

原创
2018/12/15 00:02
阅读数 1.1K

RestClientUtil and ConfigRestClientUtil have essentially the same API, with the following differences:

RestClientUtil directly executes the DSL defined in the code.

ConfigRestClientUtil gets the DSL defined in the configuration file by the DSL name and executes it. 

RestClientUtil example:

ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil();//define an instanceof RestClientUtil,It's single instance, multithreaded secure.  
List<Map> json = clientUtil.sql(Map.class,"{\\"query\\": \\"SELECT * FROM demo\\"}");  

ConfigRestClientUtil example:

ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("esmapper/sql.xml");//define an instanceof ConfigRestClientUtil,It's single instance, multithreaded secure.  
Map params = new HashMap();  
params.put("channelId",1);  
List<Map> json = clientUtil.sql(Map.class,"sqlQuery",params);  

the dsl config file:sql.xml ,We can define a lot of DSLs in the configuration file

<properties>  
    <!--  
        sql query  
    -->  
    <property name="sqlQuery">  
        <![CDATA[  
         {"query": "SELECT * FROM dbclobdemo where channelId=#[channelId]"}  
        ]]>  
    </property>  
</properties>  
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
1
分享
返回顶部
顶部