lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arturas Mazeika <maze...@gmail.com>
Subject Re: nested facets of query and terms type in JSON format
Date Thu, 03 Dec 2020 22:42:44 GMT
Hi Michael,

I wish I were able to do a percent of what you are doing. Where does your
inspiration come from? It is not from the manuals, cause I've checked
those. How do you come up with this piece of art? Did you check this from
the source code? Which lines revealed these secrets? I am eternally
grateful for your help!

Michael, maybe you happen to know how I can plugin in facet.threads
parameter in that JSON body below, so the query uses more threads to
compute the answer? I am dying out of curiosity.

Cheers,
Arturas

On Thu, Dec 3, 2020 at 7:59 PM Michael Gibney <michael@michaelgibney.net>
wrote:

> I think the first "error" case in your set of examples above is closest to
> being correct. For "query" facet type, I think you want to explicitly
> specify `"type":"query"`, and specify the query itself in the `"q"` param,
> i.e.:
> {
>     "query"  : "*:*",
>     "limit"  : 0,
>
>     "facet": {
>         "aip": {
>             "type":  "query",
>             "q":  "cfname2:aip",
>             "facet": {
>                 "t_buckets": {
>                     "type":  "range",
>                     "field": "t",
>                     "sort": { "t": "asc" },
>                     "start": "2018-05-02T17:00:00.000Z",
>                     "end":   "2020-11-16T21:00:00.000Z",
>                     "gap":   "+1HOUR"
>                     "limit": 1
>                 }
>             }
>         }
>     }
> }
>
> On Thu, Dec 3, 2020 at 12:59 PM Arturas Mazeika <mazeika@gmail.com> wrote:
>
> > Hi Michael,
> >
> > Thanks for helping me to figure this out.
> >
> > If I fire:
> >
> > {
> >     "query"  : "*:*",
> >     "limit"  : 0,
> >
> >     "facet": {
> >         "aip": { "query":  "cfname2:aip", }
> >
> >     }
> > }
> >
> > I get
> >
> > "response": { "numFound": 20560849, "start": 0, "numFoundExact": true,
> > "docs": [] }, "facets": { "count": 20560849, "aip": { "count": 2307 } } }
> >
> > (works). If I fire
> >
> >
> > {
> >     "query"  : "*:*",
> >     "limit"  : 0,
> >
> >     "facet": {
> >         "t_buckets": {
> >             "type":  "range",
> >             "field": "t",
> >             "sort": { "t": "asc" },
> >             "start": "2018-05-02T17:00:00.000Z",
> >             "end":   "2020-11-16T21:00:00.000Z",
> >             "gap":   "+1HOUR"
> >             "limit": 1
> >         }
> >     }
> > }
> >
> > I get
> >
> > "response": { "numFound": 20560849, "start": 0, "numFoundExact": true,
> > "docs": [] }, "facets": { "count": 20560849, "t_buckets": { "buckets": [
> {
> > "val": "2018-05-02T17:00:00Z", "count": 150 },
> >
> > (works). If I fire:
> >
> > {
> >     "query"  : "*:*",
> >     "limit"  : 0,
> >
> >     "facet": {
> >         "aip": { "query":  "cfname2:aip",
> >
> >             "facet": {
> >                 "t_buckets": {
> >                     "type":  "range",
> >                     "field": "t",
> >                     "sort": { "t": "asc" },
> >                     "start": "2018-05-02T17:00:00.000Z",
> >                     "end":   "2020-11-16T21:00:00.000Z",
> >                     "gap":   "+1HOUR"
> >                     "limit": 1
> >                 }
> >             }
> >         }
> >     }
> > }
> >
> > I get
> >
> > "error": { "metadata": [ "error-class",
> > "org.apache.solr.common.SolrException", "root-error-class",
> > "org.apache.solr.common.SolrException" ], "msg": "expected facet/stat
> type
> > name, like {type:range, field:price, ...} but got null , path=/facet",
> > "code": 400 } }
> >
> > If I fire
> >
> > {
> >     "query"  : "*:*",
> >     "limit"  : 0,
> >
> >     "facet": {
> >         "aip": { "query":  "cfname2:aip",
> >
> >             "facet": {
> >                 "type":  "range",
> >                 "field": "t",
> >                 "sort": { "t": "asc" },
> >                 "start": "2018-05-02T17:00:00.000Z",
> >                 "end":   "2020-11-16T21:00:00.000Z",
> >                 "gap":   "+1HOUR"
> >                 "limit": 1
> >             }
> >         }
> >     }
> > }
> >
> > I get
> >
> > "error": { "metadata": [ "error-class",
> > "org.apache.solr.common.SolrException", "root-error-class",
> > "org.apache.solr.common.SolrException" ], "msg": "expected facet/stat
> type
> > name, like {type:range, field:price, ...} but got null , path=/facet",
> > "code": 400 } }
> >
> > What else can I try out?
> >
> > Cheers,
> > Arturas
> >
> > On Thu, Dec 3, 2020 at 3:55 PM Michael Gibney <michael@michaelgibney.net
> >
> > wrote:
> >
> > > Arturas,
> > > I think your syntax is wrong for the range subfacet? -- the
> configuration
> > > of the range facet should be directly under the `tt` key, rather than
> > > nested under `t_buckets` in the request. (The response introduces a
> > > "buckets" attribute that is not part of the request syntax).
> > > Michael
> > >
> > > On Thu, Dec 3, 2020 at 3:47 AM Arturas Mazeika <mazeika@gmail.com>
> > wrote:
> > >
> > > > Hi Solr Team,
> > > >
> > > > I am trying to check how I can formulate facet queries using JSON
> > > format. I
> > > > can successfully formulate query, range, term queries, as well as
> > nested
> > > > term queries. How can I formulate a nested facet query involving
> > "query"
> > > as
> > > > well as "range" formulations? The following does not work:
> > > >
> > > >
> > > > GET http://localhost:5555/solr/db/query HTTP/1.1
> > > > content-type: application/json
> > > >
> > > > {
> > > >     "query"  : "*:*",
> > > >     "limit"  : 0,
> > > >     "facet": {
> > > >         "a1": { "query":  "cfname2:1" },
> > > >         "a2": { "query":  "cfname2:2" },
> > > >         "a3": { "field":  "cfname2", "type":"terms", "prefix":"3" },
> > > >         "a4": { "query":  "cfname2:4" },
> > > >         "a5": { "query":  "cfname2:5" },
> > > >         "a6": { "query":  "cfname2:6" },
> > > >
> > > >         "tt": {
> > > >             "t_buckets": {
> > > >                 "type":  "range",
> > > >                 "field": "t",
> > > >                 "sort": { "t": "asc" },
> > > >                 "start": "2018-05-02T17:00:00.000Z",
> > > >                 "end":   "2020-11-16T21:00:00.000Z",
> > > >                 "gap":   "+1HOUR"
> > > >             }
> > > >         }
> > > >     }
> > > > }
> > > >
> > > > Single (not nested facets separately on individual queries as well as
> > for
> > > > range) work in flying colors.
> > > >
> > > > Cheers,
> > > > Arturas
> > > >
> > >
> >
>

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