。。。。。。不带http https : 不报错 spring boot elasticsearch rest
。。。。。。不带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的更多相关文章
- Python使用requests模块访问HTTPS网站报错`certificate verify failed`
使用requests模块访问HTTPS网站报错: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Nam ...
- git https 请求报错 504
git https 请求报错 504 原因可能是因为设置了代理,ubuntu/deepin 系统可以检查 /etc/profile ~/.bashrc 内有没有设置 https 的代理. 有的话,去掉 ...
- python https请求报错:SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED]
python爬虫,使用requests库发送https请求报错:SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 解决方法: imp ...
- 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 ...
- 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 ...
- Spring Boot + Elasticsearch 实现索引批量写入
在使用Eleasticsearch进行索引维护的过程中,如果你的应用场景需要频繁的大批量的索引写入,再使用上篇中提到的维护方法的话显然效率是低下的,此时推荐使用bulkIndex来提升效率.批写入数据 ...
- Spring Boot + Elasticsearch实现大批量数据集下中文的精确匹配-案例剖析
缘由 数据存储在MYSQ库中,数据基本维持不变,但数据量又较大(几千万)放在MYSQL中查询效率上较慢,寻求一种简单有效的方式提高查询效率,MYSQL并不擅长大规模数据量下的数据查询. 技术方案 考虑 ...
- spring boot整合websocket之使用自带tomcat启动项目报错记录
项目中用到websocket,就将原来写好的websocket工具类直接拿来使用,发现前端建立连接的时候报404,经查找发现是因为原来用的是配置的外部tomcat启动,这次是spring boot自带 ...
- Https协议报错:com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl解决方法
旭日Follow_24 的CSDN 博客 ,全文地址请点击: https://blog.csdn.net/xuri24/article/details/82220333 所用应用服务器:JBoss服务 ...
随机推荐
- (转)SDL 1.2 to 2.0 Migration Guide--SDL1.2更新到SDL2.0指南
SDL 1.2 to 2.0 Migration Guide 目录 SDL 1.2 to 2.0 Migration Guide Translations Introduction Overview ...
- 在hadoop集群添加了slave节点的方法
分为以下几个步骤: 1 ,修改master和slave 的参数,和配置时相同,只是修改和节点数相关,如slaves(我的只改了slaves), 将任意一个该好的文件发送到新增加的机器(或者虚拟机) ...
- Ubuntu 安装 Kubernetes
Kubernetes是Google开源的容器集群管理系统.它构建于docker技术之上,为容器化的应用提供资源调度.部署运行.服务发现.扩容缩容等整一套功能,本质上可看作是基于容器技术的mini-Pa ...
- SQL Server--实体再复习
前些天小编所在的组织部重构.组长交给小编一项设计实体的活儿,它是我们软件灵魂(数据)的载体,实体的抽象影响到数据库设计,数据库设计的质量影响到整个程序的运营,以下是我设计的实体关系图: 系统核心业务逻 ...
- Burp Suite使用教程
http://www.nxadmin.com/tools/689.html http://tech.idv2.com/2006/08/31/burp-suite/ http://www.securit ...
- 开始iOS 7中自动布局教程(一)
本文转载至 http://www.cocoachina.com/industry/20131203/7462.html 到目前为止,如果你的设计相当的复杂,那么你必须编写大量的代码来适应这样的布局.你 ...
- windows 上驱动阻止关机重启操作
Windows 上关机重启有很多相关的操作 HOOK 一个点搞不定 具体需要以下 4 处来布控 SSDT HOOK NtInitiatePowerAction 函数 ,直接返回失败废掉这个函数 SS ...
- synchronized将任意对象作为对象监视器
多个线程调用同一个对象中的不同名称的synchronized同步方法或synchronized(this)同步代码块时,调用的效果就是按顺序执行,也就是同步的,阻塞的.这说明synchronized同 ...
- 谈谈KV存储集群的设计要点
版权声明:本文由廖念波原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/150 来源:腾云阁 https://www.qclo ...
- POJ1125-Stockbroker Grapevine Floyd算法多源最短路径
这题的思路还是比较简单,用弗洛伊德算法打表后,枚举来找到最小值 代码如下 注意最后判断时候的语句 在这里错误了很多次 # include<iostream> # include<al ...