Changeset 4501 for vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/SearchResultsDao.java
- Timestamp:
- 02/12/14 13:19:02 (10 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/SearchResultsDao.java
r4480 r4501 1 package eu.clarin.cmdi.vlo.service.impl; 1 /* 2 * Copyright (C) 2014 CLARIN 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 2 17 3 import eu.clarin.cmdi.vlo.FacetConstants; 18 package eu.clarin.cmdi.vlo.service; 19 4 20 import java.util.List; 5 21 import org.apache.solr.client.solrj.SolrQuery; 6 22 import org.apache.solr.client.solrj.response.FacetField; 7 import org.apache.solr.client.solrj.response.QueryResponse;8 23 import org.apache.solr.common.SolrDocumentList; 9 24 10 public class SearchResultsDao extends SolrDao { 25 /** 26 * 27 * @author twagoo 28 */ 29 public interface SearchResultsDao { 11 30 12 //private final static Logger LOG = LoggerFactory.getLogger(SearchResultsDao.class);31 SolrDocumentList getDocIdList(SolrQuery query); 13 32 14 private QueryResponse response;33 List<FacetField> getFacets(SolrQuery query); 15 34 16 public SearchResultsDao() { 17 super(); 18 } 19 20 public SolrDocumentList getResults(SolrQuery query) { 21 setDefaultSortField(query); 22 response = fireQuery(query); 23 SolrDocumentList results = response.getResults(); 24 return results; 25 } 26 27 public List<FacetField> getFacets(SolrQuery query) { 28 response = fireQuery(query); 29 return response.getFacetFields(); 30 } 31 32 public SolrDocumentList getDocIdList(SolrQuery query) { 33 setDefaultSortField(query); 34 query.setFields(FacetConstants.FIELD_ID); 35 query.setFacet(false); 36 query.setStart(0); 37 query.setRows(Integer.MAX_VALUE); 38 QueryResponse queryResponse = fireQuery(query); 39 return queryResponse.getResults(); 40 } 41 42 private void setDefaultSortField(SolrQuery query) { 43 if (query.getSortField() == null) { 44 query.setSortField(FacetConstants.FIELD_NAME, SolrQuery.ORDER.asc); 45 } 46 } 47 35 SolrDocumentList getResults(SolrQuery query); 36 48 37 }
Note: See TracChangeset
for help on using the changeset viewer.