。。。。。。不带http https  : 不报错

先telnet

http://onf:8080/getES653/道路桥梁正在“理疗”%20这14条道路纳入市政中修

    @GetMapping("/getES653/{requestTitle}")
public ResponseEntity getES653(@PathVariable String requestTitle) throws IOException {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
String TitleIndex = "search_title";
String TextIndex = "search_text";
long timeMillisSpent = 0;
long startEsSearch = System.currentTimeMillis();
long endEsSearch;
String res = "";
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("elastic", "aliyun"));
RestClient restClient = RestClient.builder(new HttpHost("es-cn-mpaliyun232ts.elasticsearch.aliyuncs.com", 9200))
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
}).build();
try {
String searchStrWithoutTitle = "{\"from\":0,\"size\":200,\"query\":{\"bool\":{\"should\":[{\"match\":{\"keyword\":{\"query\":\"宝宝\",\"boost\":2}}},{\"match\":{\"text\":{\"query\":\"婴幼儿,教育,家庭教育,幼儿培训,早教培训,早教课程\",\"boost\":1}}}]}},\"track_scores\":\"true\",\"sort\":[{\"weight\":{\"order\":\"desc\"}},{\"_score\":{\"order\":\"desc\"}}]}";
String searchStrWithTitle = "{\"from\":0,\"size\":200,\"query\":{\"bool\":{\"should\":{\"match\":{\"title\":{\"query\":" + requestTitle + ",\"boost\":1}}}}},\"track_scores\":\"true\",\"sort\":[{\"weight\":{\"order\":\"desc\"}},{\"_score\":{\"order\":\"desc\"}}]}";
HttpEntity httpEntity = new StringEntity(searchStrWithoutTitle, ContentType.APPLICATION_JSON); //search a document
System.out.println(searchStrWithTitle);
String endpoint = "/search_text/_search?";
Response response = restClient.performRequest("GET", endpoint,
Collections.singletonMap("pretty", "true"), httpEntity);
endEsSearch = System.currentTimeMillis();
timeMillisSpent = endEsSearch - startEsSearch;
res = EntityUtils.toString(response.getEntity());
System.out.println("searchES-TimeMillisSpent:" + timeMillisSpent); } catch (IOException e) {
e.printStackTrace();
}
String timeMillisSpentStr = Long.toString(timeMillisSpent);
JSONObject jsonObject = JSONObject.parseObject(res);
return new ResponseEntity<JSONObject>(jsonObject, HttpStatus.OK);
}

  

。。。。。。不带http https : 不报错 spring boot elasticsearch rest的更多相关文章

  1. Python使用requests模块访问HTTPS网站报错`certificate verify failed`

    使用requests模块访问HTTPS网站报错: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Nam ...

  2. git https 请求报错 504

    git https 请求报错 504 原因可能是因为设置了代理,ubuntu/deepin 系统可以检查 /etc/profile ~/.bashrc 内有没有设置 https 的代理. 有的话,去掉 ...

  3. python https请求报错:SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED]

    python爬虫,使用requests库发送https请求报错:SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 解决方法: imp ...

  4. es报错org.frameworkset.elasticsearch.ElasticSearchException: {"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],

    今天es在保存数据的时候报错 org.frameworkset.elasticsearch.ElasticSearchException: {"error":{"root ...

  5. Hp电脑开机报错:no boot disk has been detected or the disk has failed

    hp主机开机报错no boot disk has been detected  or the disk has failed,重启之后没有作用,开机之后仍然是同样界面.考虑是硬盘问题,按ESC+F10 ...

  6. Spring Boot + Elasticsearch 实现索引批量写入

    在使用Eleasticsearch进行索引维护的过程中,如果你的应用场景需要频繁的大批量的索引写入,再使用上篇中提到的维护方法的话显然效率是低下的,此时推荐使用bulkIndex来提升效率.批写入数据 ...

  7. Spring Boot + Elasticsearch实现大批量数据集下中文的精确匹配-案例剖析

    缘由 数据存储在MYSQ库中,数据基本维持不变,但数据量又较大(几千万)放在MYSQL中查询效率上较慢,寻求一种简单有效的方式提高查询效率,MYSQL并不擅长大规模数据量下的数据查询. 技术方案 考虑 ...

  8. spring boot整合websocket之使用自带tomcat启动项目报错记录

    项目中用到websocket,就将原来写好的websocket工具类直接拿来使用,发现前端建立连接的时候报404,经查找发现是因为原来用的是配置的外部tomcat启动,这次是spring boot自带 ...

  9. Https协议报错:com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl解决方法

    旭日Follow_24 的CSDN 博客 ,全文地址请点击: https://blog.csdn.net/xuri24/article/details/82220333 所用应用服务器:JBoss服务 ...

随机推荐

  1. PHPOffice下PHPWord生成Word2007(docx)使用方法

    要正常使用,下载依赖包: PhpOffice/Common:https://github.com/PHPOffice/Common Zend/Escaper:https://github.com/ze ...

  2. 转载:【原译】Erlang构建和匹配二进制数据(Efficiency Guide)

    转自:http://www.cnblogs.com/futuredo/archive/2012/10/19/2727204.html Constructing and matching binarie ...

  3. 用json在java和C#之间传递base64的问题。。。

    记录下..唉.... java代码: 导入这个 commons-codec-1.8.jar (下载链接: http://files.cnblogs.com/files/gaocong/jar%E5%8 ...

  4. MVC生成图片验证码,可指定位数

    前台: <h2>mvc后台生成验证码,可指定位数</h2> <img id="gc" src="GetValidateCode" ...

  5. 与其他Javascript类库冲突解决方案

    $(document).ready(function() { var $jq = jQuery.noConflict(); $jq('#id').show(); });

  6. zookper3.4.6集群配置

    参考链接: http://blog.csdn.net/shirdrn/article/details/7183503 个人感觉zookeeper 安装在单机上无操作意义,所以直接记录集群配置过程. 连 ...

  7. 详解JQuery Ajax 在asp.net中使用总结

    自从有了JQuery,Ajax的使用变的越来越方便了,但是使用中还是会或多或少的出现一些让人短时间内痛苦的问题.本文暂时总结一些在使用JQuery Ajax中应该注意的问题,如有不恰当或者不完善的地方 ...

  8. plsql developer中,清除登录历史

    需求描述: 在使用plsql developer的时候,发现登录的时候,有太多的历史,想要把这些登录历史清除掉, 在此记录下. 操作过程: 1.登录plsql developer(或者在登录时取消也会 ...

  9. easyui_datagrid合并行单击某行选中所有

    实现如下功能: 代码: <table id="dg" class="easyui-datagrid" title="Merge Cells fo ...

  10. VS------csc.exe已停止工作解决方法

    转载: http://blog.csdn.net/verylost/article/details/53667769 方法: 解决方法是把进程中所有的VBCSCompiler.exe进程结束掉,然后清 ...