public <T> PageModel<T> query( String[] keyWords, String[] fieldName, String indexName, String indexType, Class<T> type, Integer pageNo, Integer pageSize) throws Exception { Search.Builder search = new Search.Builder(getQueryBuilder().createMatchAllQuery(keyWords, fieldName)); search = search.addIndex(indexName).addType(indexType); search = search.setParameter("from", (pageNo - 1) * pageSize).setParameter("size", pageSize); return getJestResultConvert() .convert(elasticSearchClient.execute(search.build()), pageNo, pageSize, type); }
public <T> PageModel<T> query( String keyWork, Map<String, Float> fieldsMap, List<Sort> sorts, String indexName, String indexType, Class<T> type, boolean isFuzzy, Integer pageNo, Integer pageSize) throws Exception { Search.Builder search = new Search.Builder(getQueryBuilder().createMultiFieldQuery(keyWork, fieldsMap)); search = search.addIndex(indexName).addType(indexType); if (sorts != null && !sorts.isEmpty()) search = search.addSort(sorts); search = search.setParameter("from", (pageNo - 1) * pageSize).setParameter("size", pageSize); return getJestResultConvert() .convert(elasticSearchClient.execute(search.build()), pageNo, pageSize, type); }