You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Anil <an...@gmail.com> on 2018/11/20 08:59:13 UTC

Solr statistics

HI ,

I am using stats component to determine stats on two columns together.
stats query is failing with following exception -
*Invalid Number: num_useful  *


*Query response : *
{
  "responseHeader": {
    "zkConnected": true,
    "status": 400,
    "QTime": 19,
    "params": {
     * "q": "cid:HT201222",*
      "indent": [
        "true",
        "true"
      ],
      "stats": "true",
      "rows": [
        "0",
        "0"
      ],
      "wt": "json",
      "stats.field": "*{!func}termfreq('num_not_useful','num_useful')*"
    }
  },
  "error": {
    "metadata": [
      "error-class",
      "org.apache.solr.common.SolrException",
      "root-error-class",
      "org.apache.solr.common.SolrException"
    ],
    "msg": "Invalid Number: num_useful",
    "code": 400
  }
}

Could you please help me in resolving the issue? Thanks.

Regards,
Anil

Re: Solr statistics

Posted by Edward Ribeiro <ed...@gmail.com>.
You can get stats on multiple fields, it's just a matter of specifying the
stats.field parameter multiple times:
stats.field=field1&stats.field=field2, etc.

Besides that Solr also has a built-in sum function so that you can sum the
values of two or more fields: sum(field1, field2, ...). You could try to
use that function in a stats field.

Edward

On Tue, Nov 20, 2018 at 9:24 AM Anil <an...@gmail.com> wrote:
>
> Thanks Edward.
>
> Can we find stats on two fields ? (eg - sum = sum of (userful+not
useful)) ?
>
> On Tue, 20 Nov 2018 at 16:14, Edward Ribeiro <ed...@gmail.com>
> wrote:
>
> > You are using a function query as stats.field and as seen here:
> > https://lucene.apache.org/solr/guide/7_4/function-queries.html the
syntax
> > for termfreq is termfreq(field_name, value). You're using
> > termfreq('num_not_useful','num_useful'). It looks like num_useful is a
> > numeric (int, float) type in your schema and you are passing a string
> > ('num_useful'). If that is the case then you need to pass a numeric
value
> > (e.g., termfreq(num_not_useful, 99)). Does it make sense?
> >
> > Edward
> >
> > On Tue, Nov 20, 2018 at 6:59 AM Anil <an...@gmail.com> wrote:
> >
> > > HI ,
> > >
> > > I am using stats component to determine stats on two columns together.
> > > stats query is failing with following exception -
> > > *Invalid Number: num_useful  *
> > >
> > >
> > > *Query response : *
> > > {
> > >   "responseHeader": {
> > >     "zkConnected": true,
> > >     "status": 400,
> > >     "QTime": 19,
> > >     "params": {
> > >      * "q": "cid:HT",*
> > >       "indent": [
> > >         "true",
> > >         "true"
> > >       ],
> > >       "stats": "true",
> > >       "rows": [
> > >         "0",
> > >         "0"
> > >       ],
> > >       "wt": "json",
> > >       "stats.field":
"*{!func}termfreq('num_not_useful','num_useful')*"
> > >     }
> > >   },
> > >   "error": {
> > >     "metadata": [
> > >       "error-class",
> > >       "org.apache.solr.common.SolrException",
> > >       "root-error-class",
> > >       "org.apache.solr.common.SolrException"
> > >     ],
> > >     "msg": "Invalid Number: num_useful",
> > >     "code": 400
> > >   }
> > > }
> > >
> > > Could you please help me in resolving the issue? Thanks.
> > >
> > > Regards,
> > > Anil
> > >
> >

Re: Solr statistics

Posted by Anil <an...@gmail.com>.
Thanks Edward.

Can we find stats on two fields ? (eg - sum = sum of (userful+not useful)) ?

On Tue, 20 Nov 2018 at 16:14, Edward Ribeiro <ed...@gmail.com>
wrote:

> You are using a function query as stats.field and as seen here:
> https://lucene.apache.org/solr/guide/7_4/function-queries.html the syntax
> for termfreq is termfreq(field_name, value). You're using
> termfreq('num_not_useful','num_useful'). It looks like num_useful is a
> numeric (int, float) type in your schema and you are passing a string
> ('num_useful'). If that is the case then you need to pass a numeric value
> (e.g., termfreq(num_not_useful, 99)). Does it make sense?
>
> Edward
>
> On Tue, Nov 20, 2018 at 6:59 AM Anil <an...@gmail.com> wrote:
>
> > HI ,
> >
> > I am using stats component to determine stats on two columns together.
> > stats query is failing with following exception -
> > *Invalid Number: num_useful  *
> >
> >
> > *Query response : *
> > {
> >   "responseHeader": {
> >     "zkConnected": true,
> >     "status": 400,
> >     "QTime": 19,
> >     "params": {
> >      * "q": "cid:HT",*
> >       "indent": [
> >         "true",
> >         "true"
> >       ],
> >       "stats": "true",
> >       "rows": [
> >         "0",
> >         "0"
> >       ],
> >       "wt": "json",
> >       "stats.field": "*{!func}termfreq('num_not_useful','num_useful')*"
> >     }
> >   },
> >   "error": {
> >     "metadata": [
> >       "error-class",
> >       "org.apache.solr.common.SolrException",
> >       "root-error-class",
> >       "org.apache.solr.common.SolrException"
> >     ],
> >     "msg": "Invalid Number: num_useful",
> >     "code": 400
> >   }
> > }
> >
> > Could you please help me in resolving the issue? Thanks.
> >
> > Regards,
> > Anil
> >
>

Re: Solr statistics

Posted by Edward Ribeiro <ed...@gmail.com>.
You are using a function query as stats.field and as seen here:
https://lucene.apache.org/solr/guide/7_4/function-queries.html the syntax
for termfreq is termfreq(field_name, value). You're using
termfreq('num_not_useful','num_useful'). It looks like num_useful is a
numeric (int, float) type in your schema and you are passing a string
('num_useful'). If that is the case then you need to pass a numeric value
(e.g., termfreq(num_not_useful, 99)). Does it make sense?

Edward

On Tue, Nov 20, 2018 at 6:59 AM Anil <an...@gmail.com> wrote:

> HI ,
>
> I am using stats component to determine stats on two columns together.
> stats query is failing with following exception -
> *Invalid Number: num_useful  *
>
>
> *Query response : *
> {
>   "responseHeader": {
>     "zkConnected": true,
>     "status": 400,
>     "QTime": 19,
>     "params": {
>      * "q": "cid:HT201222",*
>       "indent": [
>         "true",
>         "true"
>       ],
>       "stats": "true",
>       "rows": [
>         "0",
>         "0"
>       ],
>       "wt": "json",
>       "stats.field": "*{!func}termfreq('num_not_useful','num_useful')*"
>     }
>   },
>   "error": {
>     "metadata": [
>       "error-class",
>       "org.apache.solr.common.SolrException",
>       "root-error-class",
>       "org.apache.solr.common.SolrException"
>     ],
>     "msg": "Invalid Number: num_useful",
>     "code": 400
>   }
> }
>
> Could you please help me in resolving the issue? Thanks.
>
> Regards,
> Anil
>