@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); } }
@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); } }