Ignore:
Timestamp:
02/12/14 13:19:02 (10 years ago)
Author:
twagoo
Message:

Created facet fields provider that uses a facet fields service to get all field objects given the current selection.
Made an implementation of this service that uses the search result dao to get the fields from the SOLR

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 */
    217
    3 import eu.clarin.cmdi.vlo.FacetConstants;
     18package eu.clarin.cmdi.vlo.service;
     19
    420import java.util.List;
    521import org.apache.solr.client.solrj.SolrQuery;
    622import org.apache.solr.client.solrj.response.FacetField;
    7 import org.apache.solr.client.solrj.response.QueryResponse;
    823import org.apache.solr.common.SolrDocumentList;
    924
    10 public class SearchResultsDao extends SolrDao {
     25/**
     26 *
     27 * @author twagoo
     28 */
     29public interface SearchResultsDao {
    1130
    12     //private final static Logger LOG = LoggerFactory.getLogger(SearchResultsDao.class);
     31    SolrDocumentList getDocIdList(SolrQuery query);
    1332
    14     private QueryResponse response;
     33    List<FacetField> getFacets(SolrQuery query);
    1534
    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   
    4837}
Note: See TracChangeset for help on using the changeset viewer.