lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <ser...@gmail.com>
Subject Re: FacetedSearch DrillDown
Date Thu, 22 Sep 2011 07:08:57 GMT
Hi Mihai,

thanks for clarifying the question. The facet module supports that quite
easily actually. I've included a sample code with some description:

(1) FacetSearchParams fsp = new FacetSearchParams();
(2) CountFacetRequest facetRequest = new CountFacetRequest(new
CategoryPath("monday"), 10);
(3) facetRequest.setDepth(3);
(4) fsp.addFacetRequest(facetRequest);
(5) FacetsCollector col = new FacetsCollector(fsp,
searcher.getIndexReader(), taxoReader);
(6) searcher.search(new MatchAllDocsQuery(), col);
(7) System.out.println(col.getFacetResults().get(0));

Explanation:
(1) -- create FacetSearchParams with the default FacetIndexingParams. This
is the common case.
(2) -- Create CountFacetRequest, for the 'monday' node (which is the
top-level node in your example), and specify that the top-10 counted
categories should be returned.
(3) -- Specify depth=3, which means that the top-K (10 in this example)
should be computed among all nodes up to depth '3'.
(4) -- add the FacetRequest to the search params.
(5) -- Create the FacetsCollector
(6) -- Issue the search
(7) -- Print the result, in this case only one FacetResult exists because
only one dimension (FacetRequest) was asked.

This prints the following:

Request: monday nRes=10 nLbl=10
Num valid Descendants (up to specified depth): 5
    Facet Result Node with 5 sub result nodes.
    Name: monday
    Value: 3.0
    Residue: 0.0

    Subresult #0
        Facet Result Node with 0 sub result nodes.
        Name: monday/1pm
        Value: 2.0
        Residue: 0.0

    Subresult #1
        Facet Result Node with 0 sub result nodes.
        Name: monday/2pm/3min
        Value: 1.0
        Residue: 0.0

    Subresult #2
        Facet Result Node with 0 sub result nodes.
        Name: monday/2pm
        Value: 1.0
        Residue: 0.0

    Subresult #3
        Facet Result Node with 0 sub result nodes.
        Name: monday/1pm/4min
        Value: 1.0
        Residue: 0.0

    Subresult #4
        Facet Result Node with 0 sub result nodes.
        Name: monday/1pm/3min
        Value: 1.0
        Residue: 0.0

I believe that's what you were looking for?

The DrillDown class provide helper utility methods for drilling-down on a
selected facet. I.e., if you return the user the above results, and he
clicks on "Monday/1pm", you want to constraint the search to this category
only. The DrillDown class helps you create a Query out of the user's
selection.

We wrote a very extensive userguide which unfortunately didn't make it into
the release. I've attached its PDF version in this issue:
https://issues.apache.org/jira/browse/LUCENE-3261. I intend to make an HTML
version out of it, so that it will be included with future releases.
Apologies for the delay.

Shai

On Wed, Sep 21, 2011 at 10:44 PM, Mihai Caraman <caraman.mihai@gmail.com>wrote:

> monday, 1pm,  3min

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message