我想使用Java客户端从弹性搜索文档的特定字段中获取2个字段:
public SearchResponse getResponse(String index) {
SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.searchSource();
SearchResponse response = elasticHandler.prepareSearch()
.setIndices(index)
.setQuery(QueryBuilders.termsQuery("provider", "twitter"))
.setSource(searchSourceBuilder)
.setFetchSource((new String[] {"originId","name"}), null)
.setSize(scrollSize).get();
return response;
}
但是,包含两个字段originId
和name
的地图为空。
你能帮我吗?