zoukankan      html  css  js  c++  java
  • elasticsearch scroll api--jestclient invoke

    @Test
    	public void testScroll(){
    		JestClientFactory factory = new JestClientFactory();
    		factory.setHttpClientConfig(new HttpClientConfig.Builder(Constants.ElasticSearch_Server).multiThreaded(true).readTimeout(300000).build());
    		JestClient client = factory.getObject();
    		String query = "{" +
    				"    "query":{" +
    				"        "match":{"srv_content":"google"}}" +
    				"    }" +
    				"}";
    
    		try {
    			Search search=new Search.Builder(query).addIndex("ipv4geo").addType("service").setParameter(Parameters.SIZE,5000).setParameter(Parameters.SCROLL,"5m").build();
    			JestResult result = client.execute(search);
    			String scrollId = result.getJsonObject().get("_scroll_id").getAsString();
    			System.out.println(scrollId);
    			for (int i=1; i< 10; i++){
    				SearchScroll scroll = new SearchScroll.Builder(scrollId,"5m").build();
                    result = client.execute(scroll);
    				List<IPv4> iPv4List = result.getSourceAsObjectList(IPv4.class);
    				System.out.println("===============================================");
    				if (iPv4List != null){
    					System.out.println(iPv4List.get(0).getIp());
    					System.out.println(iPv4List.size());
    				}
    			}
    
    
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
  • 相关阅读:
    k8s pod 定义 文件 yaml
    动态规划(1)
    Angular封装WangEditor富文本组件
    使用Angular CDK实现一个Service弹出Toast组件
    让Angular自定义组件支持form表单验证
    等了半年,m1芯片原生支持的.NET IDE出现了
    eachrt
    dgy
    开源节流
    company
  • 原文地址:https://www.cnblogs.com/mayidudu/p/6069839.html
Copyright © 2011-2022 走看看