
直接使用 postman 调用 用时一秒
http://106.13.148.210:9200/_search { "query": { "match": { "book_id": { "query": 87, "operator": "OR", "prefix_length": 0, "max_expansions": 50, "fuzzy_transpositions": true, "lenient": false, "zero_terms_query": "NONE", "auto_generate_synonyms_phrase_query": true, "boost": 1 } } }, "size": 500 } 使用 java 代码 8 秒多
/* SearchRequest searchRequest = new SearchRequest("web_book_chapter"); SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("book_id", 48); // matchQueryBuilder. sourceBuilder.query(matchQueryBuilder); sourceBuilder.size(200); System.out.println(sourceBuilder.toString()); sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS)); searchRequest.source(sourceBuilder); long startTime=System.currentTimeMillis(); try { SearchResponse searchRespOnse= client.search(searchRequest, RequestOptions.DEFAULT); long endTime=System.currentTimeMillis(); System.out.println("程序运行时间: "+(endTime - startTime)+"ms"); SearchHits hits = searchResponse.getHits(); SearchHit[] searchHits = hits.getHits(); for (SearchHit hit : searchHits) { String sourceAsString = hit.getSourceAsString(); BookChapterModel bookChapterModel = JSON.parseObject(sourceAsString, BookChapterModel.class); list.add(bookChapterModel); } }catch (Exception e){ e.printStackTrace(); } @Bean public RestHighLevelClient restHighLevelClient(){ long startTime=System.currentTimeMillis(); RestHighLevelClient restHighLevelClient = new RestHighLevelClient( RestClient.builder( new HttpHost("106.13.148.210", 9200,"http") ) ); long endTime=System.currentTimeMillis(); System.out.println("初始化客户端时间: "+(endTime - startTime)+"ms"); return restHighLevelClient; } 1 wei672520619 2020-07-10 10:28:40 +08:00 老铁,问题解决了么,我也遇到这个问题了,请指教一下 |
2 slleong 2020-07-10 10:32:07 +08:00 巧了,我也遇到了,楼主,楼上解决了也回一下 |
3 ztianyijiu1 2020-07-10 17:57:48 +08:00 @slleong 把 sourceBuilder.toString 打印出来,对比下有没有不同,如果完全一样还是这种情况,就放弃吧 |
4 1406075864 OP 我把配置里的外网地址改成 localhost:9300 就好了 |
5/span> 1406075864 OP 我把配置里的外网地址改成 localhost:9300 就好了 , |
6 1406075864 OP 具体是什么问题没有分析出来 如果做 es 的集群不知道会不会还出问题 |