Skip to content

Instantly share code, notes, and snippets.

@gizemabali
Created March 15, 2019 07:44
Show Gist options
  • Save gizemabali/e81d3483f79894a0a8922d183b0478ba to your computer and use it in GitHub Desktop.
Save gizemabali/e81d3483f79894a0a8922d183b0478ba to your computer and use it in GitHub Desktop.
// ...
// create client
ElasticsearchClient client = new ElasticsearchClient();
String startDateStr = "2018-10-01T00:00:00.000Z";
String endDateStr = "2019-03-15T00:00:00.000Z";
QueryBuilder query = QueryBuilders.matchQuery(<key>, <Id>);
SearchRequestBuilder searchBuilder = client.prepareSearch();
SearchResponse scrollResp = searchBuilder.setIndices(<index_name>).setTypes(<index_type_name>).setQuery(query)
.setPostFilter(QueryBuilders.rangeQuery(TIMESTAMP).from(startDateStr).to(endDateStr))
.setSize(MAX_BULK_SIZE).setScroll(KEEP_ALIVE_FIVE_MINUTE).execute().actionGet();
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment