Example #1
0
 private SearchPaging buildPaging(ContentRequest req) {
   SearchPaging paging = new SearchPaging();
   int page = req.getIntParameter("page", 1);
   int results = req.getIntParameter("results", 100);
   paging.setPage(page);
   paging.setHitsPerPage(results);
   return paging;
 }
Example #2
0
 @Override
 public void processMultiple(Collection<IndexMaster> indexes, ContentRequest req, XMLWriter xml)
     throws BerliozException, IOException {
   String facets = req.getParameter("facets", "");
   int maxNumber = req.getIntParameter("max-facets", 20);
   // get first catalog as they should all have the same one
   SearchQuery query = buildQuery(req, indexes.iterator().next().getCatalog());
   if (query == null) {
     xml.emptyElement("index-search");
     return;
   }
   SearchPaging paging = buildPaging(req);
   ArrayList<Index> theIndexes = new ArrayList<Index>();
   for (IndexMaster index : indexes) {
     theIndexes.add(index.getIndex());
   }
   try {
     SearchResults results = LuceneIndexQueries.query(theIndexes, query, paging);
     List<FieldFacet> facetsList =
         Facets.getFacets(
             Arrays.asList(facets.split(",")), maxNumber, query.toQuery(), theIndexes);
     outputResults(query, results, facetsList, xml);
   } catch (IndexException ex) {
     LOGGER.warn(
         "Fail to retrieve search result using query: {}", (Object) query.toString(), (Object) ex);
   }
 }
Example #3
0
 @Override
 public void processSingle(IndexMaster index, ContentRequest req, XMLWriter xml)
     throws BerliozException, IOException {
   String facets = req.getParameter("facets", "");
   int maxNumber = req.getIntParameter("max-facets", 20);
   SearchQuery query = buildQuery(req, index.getCatalog());
   if (query == null) {
     xml.emptyElement("index-search");
     return;
   }
   SearchPaging paging = buildPaging(req);
   try {
     SearchResults results = index.query(query, paging);
     List<FieldFacet> facetsList =
         Facets.getFacets(
             Arrays.asList(facets.split(",")), maxNumber, query.toQuery(), index.getIndex());
     outputResults(query, results, facetsList, xml);
   } catch (IndexException ex) {
     LOGGER.warn(
         "Fail to retrieve search result using query: {}", (Object) query.toString(), (Object) ex);
   }
 }