spring data elasticsearch 执行 dsl json 查询语句

tech2023-05-09  124

基于SearchTemplateRequest 实现。支持参数替换。 SearchTemplateRequest request = new SearchTemplateRequest(); request.setRequest(new SearchRequest(INDEX_NAME)); request.setScriptType(ScriptType.INLINE); request.setScript(querySql); Map<String, Object> scriptParams = new HashMap<>(); request.setScriptParams(scriptParams);  实现调用 SearchTemplateResponse searchTemplateResponse = elasticsearchRestTemplate.getClient().searchTemplate(request, RequestOptions.DEFAULT); SearchResponse response = searchTemplateResponse.getResponse();

 

最新回复(0)