java连接es:
1、接口:
/**
* 查询(单个或多个)type所有数据,条件查询,分页查询,排序
* @param client
* @param indexName
* @param typeName
*/
public void searchAllStudent(TransportClient client, String indexName, String typeName);
2.实现类:(注释!!)
@Override
public void searchAllStudent(TransportClient client, String indexName, String typeName) {
// 多索引,多type查询
// SearchResponse searchResponse = client.prepareSearch("shb01","shb02").setTypes("stu","tea")
//创建SearchResponse对象
SearchResponse searchResponse = client.prepareSearch(indexName)
.setTypes(typeName)
//查询所有
.setQuery(QueryBuilders.matchAllQuery())
.setSearchType(SearchType.QUERY_THEN_FETCH)