Scroll Search Multiple Fields

Hi, I want to do a Scroll search only for some fields, I have 5 fields like this: name, content, type_message, status and date and I want to get only 2 fields with a search scroll. I have this:

SearchResponse scroll_traffic = client.prepareSearch(index)
.setScroll(new TimeValue(6000))

But I want to add fields to filter my search, How can I do that with scroll?


				.addFields("field1", "field2", "field3", "etc..."
						.setScroll(new TimeValue(...))

Also when you read ScrollResponse, you will not get back hits but rather fields...

for (SearchHit hit : scrollResp.getHits().getHits()) {
    String line = new String();
    // Quick dirty way to format as CSV.    			    	
 	for(Entry<String, SearchHitField> e : hit.fields().entrySet()){
    		line += "\"" + e.getValue().value().toString() + "\",";
    line += "\r\n";
1 Like

Trank you so much