OK. Kinda like pivoting stats...

http://localhost:8983/solr/select?q=*%3A*&wt=json&indent=true&olap=true&olap.req1.fieldfacet=overall_score&facet=true&facet.field=overall_score&olap.req1.statistic.count=count(overall_score)

Basically this does the same think in olap and facet.


   - response:
   {
      - numFound: 63061,
      - start: 0,
      - docs:
      []
      },
   - facet_counts:
   {
      - facet_queries: { },
      - facet_fields:
      {
         - overall_score:
         [
            - "1",
            - 40138,
            - "5",
            - 17487,
            - "2",
            - 2299,
            - "4",
            - 1810,
            - "3",
            - 1314
            ]
         },
      - facet_dates: { },
      - facet_ranges: { },
      - facet_intervals: { },
      - facet_heatmaps: { }
      },
   - stats:
   [
      - "req1",
      -
      [
         - "count",
         - 63048,
         - "fieldFacets",
         -
         [
            - "overall_score",
            -
            [
               - "1",
               -
               [
                  - "count",
                  - 40138
                  ],
               - "2",
               -
               [
                  - "count",
                  - 2299
                  ],
               - "3",
               -
               [
                  - "count",
                  - 1314
                  ],
               - "4",
               -
               [
                  - "count",
                  - 1810
                  ],
               - "5",
               -
               [
                  - "count",
                  - 17487
                  ]
               ]
            ],
         - "rangeFacets",
         - [ ],
         - "queryFacets",
         - [ ]
         ]
      ]

}


On Sat, Jun 13, 2015 at 2:06 PM, William Bell <billnb...@gmail.com> wrote:

> Having a hard time getting this to work:
>
>
> http://localhost:8983/solr/select?q=*%3A*&wt=json&indent=true&olap=true&olap.req1.fieldfacet=overall_score
>
>
> and even tried... I made sure docValues was set for overall_score too.
>
>
> http://hgsolr2devmstr:8983/solr/survey/select?q=*%3A*&wt=json&indent=true&olap=true&olap.fieldfacet=overall_score
>
> <field name="overall_score" type="int" indexed="true" stored="true"
> docValues="true" />
>
> On Sat, Jun 13, 2015 at 2:02 PM, William Bell <billnb...@gmail.com> wrote:
>
>> Not you need to enable docValues to get range stuff to work.
>>
>> docValues="true" on the field.
>>
>> On Sat, Jun 13, 2015 at 1:37 PM, William Bell <billnb...@gmail.com>
>> wrote:
>>
>>> OK. That works with one more change.
>>>
>>> <lib dir="../../../dist/" regex="solr-analytics-.*\.jar" />
>>>
>>>  <lib dir="../../../dist/" regex="solr-analysis-.*\.jar" />
>>>
>>>
>>> http://localhost:8983/solr/select?q=*%3A*&wt=json&indent=true&stats=true&olap=true&olap.overall_score.statistic.sum=sum(overall_score)
>>>
>>> On Sat, Jun 13, 2015 at 1:16 PM, William Bell <billnb...@gmail.com>
>>> wrote:
>>>
>>>> OK more info
>>>>
>>>> <requestHandler name="standard" class="solr.StandardRequestHandler">
>>>>     <arr name="components">
>>>>       <str>query</str>
>>>>       <str>facet</str>
>>>>       <str>analytics</str>
>>>>       <str>highlight</str>
>>>>       <str>debug</str>
>>>>       <str>expand</str>
>>>>     </arr>
>>>>   </requestHandler>
>>>>
>>>>
>>>> <searchComponent name="analytics" 
>>>> class="org.apache.solr.handler.component.AnalyticsComponent" />
>>>>
>>>> I am going to try that after adding it to solrconfig.xml.
>>>>
>>>>
>>>>
>>>> On Sat, Jun 13, 2015 at 1:11 PM, William Bell <billnb...@gmail.com>
>>>> wrote:
>>>>
>>>>> Same here.
>>>>>
>>>>> What do we need to add to solrconfig.xml to get it to work?
>>>>>
>>>>>
>>>>>    1. SOLR-5302 <https://issues.apache.org/jira/browse/SOLR-5302>
>>>>>    2.
>>>>>    3. Help/
>>>>>
>>>>>
>>>>> On Sat, Jun 13, 2015 at 8:34 AM, kingofhypocrites <
>>>>> kingofhypocri...@gmail.com> wrote:
>>>>>
>>>>>> This looks very promising if only I could get it to work:
>>>>>> https://issues.apache.org/jira/browse/SOLR-5302
>>>>>>
>>>>>> https://issues.apache.org/jira/secure/attachment/12606793/Search%20Analytics%20Component.pdf
>>>>>>
>>>>>> Various links it points to are broken now and i can't find anything
>>>>>> about
>>>>>> it online, but the PDF indicates I can set olap=true to turn it on,
>>>>>> although this doesn't seem to do anything. The docs say it supports
>>>>>> limiting the results and doing math operations on statistics which is
>>>>>> exactly what I need. I'm not clear if I need to install this or if
>>>>>> this
>>>>>> component is even used anymore.
>>>>>>
>>>>>> On Fri, Jun 12, 2015 at 12:00 PM Joel Bernstein [via Lucene] <
>>>>>> ml-node+s472066n4211422...@n3.nabble.com> wrote:
>>>>>>
>>>>>> > https://issues.apache.org/jira/browse/SOLR-7560, will almost
>>>>>> support this
>>>>>> > in Solr 5.3. The compound function support won't be there yet
>>>>>> though. But
>>>>>> > it will be there in the near future.
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > Joel Bernstein
>>>>>> > http://joelsolr.blogspot.com/
>>>>>> >
>>>>>> > On Fri, Jun 12, 2015 at 9:30 AM, kingofhypocrites <
>>>>>> > [hidden email] <http://
>>>>>> /user/SendEmail.jtp?type=node&node=4211422&i=0>>
>>>>>> > wrote:
>>>>>> >
>>>>>> > > I am migrating a database from SQL Server to Cassandra. Currently
>>>>>> I have
>>>>>> > a
>>>>>> > > setup as follows:
>>>>>> > >
>>>>>> > > - Log data in Cassandra
>>>>>> > > - Summarize data in Spark and put into Cassandra summary tables
>>>>>> > > - Query data in Solr
>>>>>> > >
>>>>>> > > Everything fits beautifully until I need to do stats on groups. I
>>>>>> am
>>>>>> > hoping
>>>>>> > > to get this to work with Solr so I can stick to one database, but
>>>>>> I am
>>>>>> > not
>>>>>> > > sure it's possible.
>>>>>> > >
>>>>>> > > If I had it in SQL Server, I could do it like so:
>>>>>> > > SELECT
>>>>>> > >     site_id,
>>>>>> > >     keyword,
>>>>>> > >     SUM(visits) as visits,
>>>>>> > >     CONVERT(DECIMAL(13, 3), SUM(bounces)) / SUM(visits) as
>>>>>> bounce_rate,
>>>>>> > >     SUM(pageviews) as pageviews,
>>>>>> > >     CONVERT(DECIMAL(13, 3), SUM(pageviews)) / SUM(visits) as
>>>>>> > > avg_pages_per_visit
>>>>>> > > FROM
>>>>>> > >     report_all_keywords_daily
>>>>>> > > WHERE
>>>>>> > >     site_id = 55 AND date_key >= '20150606' AND date_key <=
>>>>>> '20150608'
>>>>>> > > GROUP BY
>>>>>> > >     site_id, keyword
>>>>>> > > ORDER BY visits DESC
>>>>>> > >
>>>>>> > > Now I need to replicate this in Solr. The closest I could get to
>>>>>> this is
>>>>>> > by
>>>>>> > > using the Stats component and then using field collapsing.
>>>>>> > >
>>>>>> > >
>>>>>> >
>>>>>> group=true&group.field=keyword&stats=true&stats.field=visits&stats.facet=keyword
>>>>>> >
>>>>>> > >
>>>>>> > > And here are some results I get back:
>>>>>> > > http://pastebin.com/raw.php?i=Fxhe2RA0
>>>>>> > >
>>>>>> > > However, I need to do able to divide certain metrics. I tried
>>>>>> including
>>>>>> > > functions in the stats.field such as div(sum(bounce_rate),
>>>>>> (sum(visits))
>>>>>> > > but
>>>>>> > > it doesn't recognize the functions. Also it seems to ignoring the
>>>>>> paging
>>>>>> > > for
>>>>>> > > the stats results and returns all groups regardless.
>>>>>> > >
>>>>>> > > Ultimately I'd like something like this which is what I would get
>>>>>> in
>>>>>> > SQL:
>>>>>> > > <http://lucene.472066.n3.nabble.com/file/n4211402/pic.png>
>>>>>> > >
>>>>>> > > Is this possible or do I have to give up on the prospect of using
>>>>>> Solr?
>>>>>> > I
>>>>>> > > have to query this data dynamically so I can't pre-summarize all
>>>>>> of it.
>>>>>> > >
>>>>>> > > To clarify I having the following two problems:
>>>>>> > > - Paging is ignored for stats data
>>>>>> > > - I can't figure out how to divide two stats together to get a
>>>>>> third
>>>>>> > stat.
>>>>>> > > Note: In some cases I would need to be able to sort on this
>>>>>> combined
>>>>>> > stat
>>>>>> > >
>>>>>> > >
>>>>>> > >
>>>>>> > > --
>>>>>> > > View this message in context:
>>>>>> > >
>>>>>> >
>>>>>> http://lucene.472066.n3.nabble.com/Division-with-Stats-Component-when-Grouping-in-Solr-tp4211402.html
>>>>>> > > Sent from the Solr - User mailing list archive at Nabble.com.
>>>>>> > >
>>>>>> >
>>>>>> >
>>>>>> > ------------------------------
>>>>>> >  If you reply to this email, your message will be added to the
>>>>>> discussion
>>>>>> > below:
>>>>>> >
>>>>>> >
>>>>>> http://lucene.472066.n3.nabble.com/Division-with-Stats-Component-when-Grouping-in-Solr-tp4211402p4211422.html
>>>>>> >  To unsubscribe from Division with Stats Component when Grouping in
>>>>>> Solr, click
>>>>>> > here
>>>>>> > <
>>>>>> http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4211402&code=a2luZ29maHlwb2NyaXRlc0BnbWFpbC5jb218NDIxMTQwMnwtNDY4MDgyMzk1
>>>>>> >
>>>>>> > .
>>>>>> > NAML
>>>>>> > <
>>>>>> http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>>>>>> >
>>>>>> >
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://lucene.472066.n3.nabble.com/Division-with-Stats-Component-when-Grouping-in-Solr-tp4211402p4211525.html
>>>>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Bill Bell
>>>>> billnb...@gmail.com
>>>>> cell 720-256-8076
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Bill Bell
>>>> billnb...@gmail.com
>>>> cell 720-256-8076
>>>>
>>>
>>>
>>>
>>> --
>>> Bill Bell
>>> billnb...@gmail.com
>>> cell 720-256-8076
>>>
>>
>>
>>
>> --
>> Bill Bell
>> billnb...@gmail.com
>> cell 720-256-8076
>>
>
>
>
> --
> Bill Bell
> billnb...@gmail.com
> cell 720-256-8076
>



-- 
Bill Bell
billnb...@gmail.com
cell 720-256-8076

Reply via email to