Exemple #1
0
    def searchWithDrillDown(cls, drilldownCategory, indexReader, taxoReader, facets_config):
        """
        Search an index with facets drill-down.
        return a list of FacetResult instances
        """
        #  User drills down on 'Categories' "root/a/f1" and we return facets for 'Author'
        searcher = IndexSearcher(indexReader)
        #  Passing no baseQuery means we drill down on all documents ("browse only"):
        query =  DrillDownQuery(facets_config)
        # Now user drills down on Publish Date/2010:
        query.add("Categories",  drilldownCategory)
        facets_collector = FacetsCollector()
        FacetsCollector.search(searcher, query, 10, facets_collector)
        # Retrieve results
        facets =  FastTaxonomyFacetCounts(taxoReader, facets_config, facets_collector)
        facet_result = facets.getTopChildren(10, "Author")
        print  "Author: ", facet_result.childCount
        for  lv in facet_result.labelValues:
            print " '%s' (%s)"  % (lv.label, lv.value)

        return facet_result
Exemple #2
0
    def searchWithQuery(cls, query, indexReader, taxoReader, facets_config):
        """
        Search an index with facets for a given query
        return a list of FacetResult instances
        """
        # prepare searcher to search against
        searcher = IndexSearcher(indexReader)
        # create a FacetsCollector to use in our facetted search:
        facets_collector = FacetsCollector()
        FacetsCollector.search(searcher, query, 10, facets_collector)
        # Count both "Categories" and "Author" dimensions
        facets = FastTaxonomyFacetCounts(taxoReader, facets_config, facets_collector)
        results = []

        facet_result = facets.getTopChildren(10, "Categories")
        if facet_result:
            results.append(facet_result)
            print  "Categories: ", facet_result.childCount
            for  lv in facet_result.labelValues:
                print " '%s' (%s)"  % (lv.label, lv.value)

        facet_result = facets.getTopChildren(10, "Categories", "root", "a")
        if facet_result:
            results.append(facet_result)
            print  "Root-a-Categories: ", facet_result.childCount
            for  lv in facet_result.labelValues:
                print " '%s' (%s)"  % (lv.label, lv.value)

        facet_result = facets.getTopChildren(10, "Author")
        if facet_result:
            results.append(facet_result)
            print  "Author: ", facet_result.childCount
            for  lv in facet_result.labelValues:
                print " '%s' (%s)"  % (lv.label, lv.value)

        return results