Home > Back-end > Help RestHighLevelClient query ES, search method automatically compile full URL in 404
Help RestHighLevelClient query ES, search method automatically compile full URL in 404
Time:09-16
The code is as follows:
Public static void main (String [] args) throws the Exception { The SearchRequest SearchRequest=new SearchRequest (" common/elasticsearch - test "); The searchRequest. Types (" the frequent - appear "); Int fromIndex=0; Int pageSize=50; The searchRequest. Source (new SearchSourceBuilder () The query (QueryBuilders. TermQuery (" id ", "1998")) The from (fromIndex). The size (pageSize). Sort (" count ")); The SearchResponse response; RestHighLevelClient RestHighLevelClient; EsManager EsManager=new EsManager (" 192.168.120.12 ", 30000); RestHighLevelClient=esManager. GetClient (); The response=restHighLevelClient. Search (searchRequest); System. The out. Println (response. GetHits () getHits (.) length); RestHighLevelClient. Close (); }
After joining together the full path to the right should be: http://192.168.120.12:30000/common/elasticsearch-test/frequent-appear/_search? Typed_keys=true& Ignore_unavailable=false& Expand_wildcards=open& Allow_no_indices=true& Search_type=query_then_fetch & amp; Batched_reduce_size=512
But transformed to: http://192.168.120.12:30000/common%2Felasticsearch-test/frequent-appear/_search? Typed_keys=true& Ignore_unavailable=false& Expand_wildcards=open& Allow_no_indices=true& Search_type=query_then_fetch & amp; Batched_reduce_size=512
The path of/transformed into % 2 f
CSDN the great god for help!
CodePudding user response:
RestHighLevelClient client=new RestHighLevelClient ( RestClient. Builder ( New HttpHost (IP, Integer. The valueOf (port), "HTTP")));