Lucene - Core
  1. Lucene - Core
  2. LUCENE-5298

Allow aggregating facets by any ValueSource

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.6, Trunk
    • Component/s: modules/facet
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      Facets can be aggregated today by counting them, aggregating by summing their association values, or summing the scores of the documents. Applications can write their own FacetsAggregator to compute the value of the facet in other ways. Following the new expressions module, I think it will be interesting to allow aggregating facets by arbitrary expressions, e.g. _score * sqrt(price) where 'price' is an NDV field. I'd like to explore allowing any ValueSource to be passed in and write a ValueSourceFacetsAggregator.

      1. LUCENE-5298.patch
        27 kB
        Shai Erera
      2. LUCENE-5298.patch
        27 kB
        Shai Erera

        Activity

        Hide
        Shai Erera added a comment -

        Patch adds ValueSourceFacetRequest which takes a ValueSource and creates a FacetsAggregator which aggregates by the values returned from ValueSource for documents. The app needs to specify whether the ValueSource requires document scores, and a matching aggregator is created accordingly.

        Also added an example to demo/ of aggregating by an expression.

        Note that this adds a dependency of facet/ on queries/ because ValueSource and FunctionValues are there. If they'll move the core/ one day, we can remove the dependency.

        Show
        Shai Erera added a comment - Patch adds ValueSourceFacetRequest which takes a ValueSource and creates a FacetsAggregator which aggregates by the values returned from ValueSource for documents. The app needs to specify whether the ValueSource requires document scores, and a matching aggregator is created accordingly. Also added an example to demo/ of aggregating by an expression. Note that this adds a dependency of facet/ on queries/ because ValueSource and FunctionValues are there. If they'll move the core/ one day, we can remove the dependency.
        Hide
        Shai Erera added a comment -

        Same patch only renamed to SumValueSourceFacetRequest and improved its javadocs.

        Show
        Shai Erera added a comment - Same patch only renamed to SumValueSourceFacetRequest and improved its javadocs.
        Hide
        Robert Muir added a comment -

        +1, looks cool.

        I agree we should investigate the functionvalues stuff (maybe a followup issue to look at these apis?) Its making the dependency situation complex just because the abstract API is where it is today. Instead we could do the usual trick like analysis and have some mock stuff for testing and so on.

        Show
        Robert Muir added a comment - +1, looks cool. I agree we should investigate the functionvalues stuff (maybe a followup issue to look at these apis?) Its making the dependency situation complex just because the abstract API is where it is today. Instead we could do the usual trick like analysis and have some mock stuff for testing and so on.
        Hide
        Shai Erera added a comment -

        In order to compile, we need to have ValueSource and FunctionValues under core/ (same package though I think?). We can also think about moving FunctionQuery too, though that's less of an issue, as you can always test using a CustomScoreQuery with a CustomScoreProvider which computes the score from the ValueSource (if you're interested in a score-dependent ValueSource). And it's quite easy to implement a MockValueSource. I agree though that we should do that under a different issue. Is that what you had in mind?

        Show
        Shai Erera added a comment - In order to compile, we need to have ValueSource and FunctionValues under core/ (same package though I think?). We can also think about moving FunctionQuery too, though that's less of an issue, as you can always test using a CustomScoreQuery with a CustomScoreProvider which computes the score from the ValueSource (if you're interested in a score-dependent ValueSource). And it's quite easy to implement a MockValueSource. I agree though that we should do that under a different issue. Is that what you had in mind?
        Hide
        Robert Muir added a comment -

        yes, exactly. because of where the abstract API is (mis)placed there are many unnecessary and confusing dependencies. we should eliminate the suggest/ dependencies on expressions and queries, the expressions/ on queries, the grouping/ dependency on queries, the spatial/ dependency on queries, its a mess.

        Show
        Robert Muir added a comment - yes, exactly. because of where the abstract API is (mis)placed there are many unnecessary and confusing dependencies. we should eliminate the suggest/ dependencies on expressions and queries, the expressions/ on queries, the grouping/ dependency on queries, the spatial/ dependency on queries, its a mess.
        Hide
        Shai Erera added a comment -

        ok I opened LUCENE-5325.

        Show
        Shai Erera added a comment - ok I opened LUCENE-5325 .
        Hide
        ASF subversion and git services added a comment -

        Commit 1538431 from Shai Erera in branch 'dev/trunk'
        [ https://svn.apache.org/r1538431 ]

        LUCENE-5298: add SumValueSourceFacetRequest

        Show
        ASF subversion and git services added a comment - Commit 1538431 from Shai Erera in branch 'dev/trunk' [ https://svn.apache.org/r1538431 ] LUCENE-5298 : add SumValueSourceFacetRequest
        Hide
        ASF subversion and git services added a comment -

        Commit 1538433 from Shai Erera in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1538433 ]

        LUCENE-5298: add SumValueSourceFacetRequest

        Show
        ASF subversion and git services added a comment - Commit 1538433 from Shai Erera in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1538433 ] LUCENE-5298 : add SumValueSourceFacetRequest
        Hide
        Shai Erera added a comment -

        Committed to trunk and 4x.

        Show
        Shai Erera added a comment - Committed to trunk and 4x.
        Hide
        ASF subversion and git services added a comment -

        Commit 1538445 from Shai Erera in branch 'dev/trunk'
        [ https://svn.apache.org/r1538445 ]

        LUCENE-5298: add missing svn:eol-style

        Show
        ASF subversion and git services added a comment - Commit 1538445 from Shai Erera in branch 'dev/trunk' [ https://svn.apache.org/r1538445 ] LUCENE-5298 : add missing svn:eol-style
        Hide
        ASF subversion and git services added a comment -

        Commit 1538446 from Shai Erera in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1538446 ]

        LUCENE-5298: add missing svn:eol-style

        Show
        ASF subversion and git services added a comment - Commit 1538446 from Shai Erera in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1538446 ] LUCENE-5298 : add missing svn:eol-style
        Hide
        ASF subversion and git services added a comment -

        Commit 1538551 from Shai Erera in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1538551 ]

        LUCENE-5298: suppress 3x codec

        Show
        ASF subversion and git services added a comment - Commit 1538551 from Shai Erera in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1538551 ] LUCENE-5298 : suppress 3x codec
        Hide
        ASF subversion and git services added a comment -

        Commit 1539541 from Steve Rowe in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1539541 ]

        LUCENE-5298: Maven config: add new lucene-queries dependency to the lucene-facet module; add new lucene-queries and lucene-expressions dependencies to the lucene-demo module

        Show
        ASF subversion and git services added a comment - Commit 1539541 from Steve Rowe in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1539541 ] LUCENE-5298 : Maven config: add new lucene-queries dependency to the lucene-facet module; add new lucene-queries and lucene-expressions dependencies to the lucene-demo module

          People

          • Assignee:
            Shai Erera
            Reporter:
            Shai Erera
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development