Rewriting:
*) 
https://lucene.apache.org/solr/guide/8_8/json-request-api.html#json-parameter-merging
, there is a way to represent most (all?) of the structure with json.x
parameter.
*) Also, you can create custom Request Handlers in solrconfig.xml with
a lot of those parameters either as defaults (overridable or not) or
as paramsets and refer to them by name with useParams in file or in
query ( 
https://lucene.apache.org/solr/guide/8_8/request-parameters-api.html#the-useparams-parameter)

Sorting: not so sure, but I wonder if you can inject a synthetic field
or function to do 'max/min' on the date even under the category (as a
3rd level nesting)?

Also, another approach that came to me afterwards was to use
relatedness: 
https://lucene.apache.org/solr/guide/8_8/json-facet-api.html#relatedness-and-semantic-knowledge-graphs
and try to identify categories with foreground being recent-date-range
and the background being everything (or relevant subset of such). This
may be cloud-only and totally may not work. I had some education
material related to this at slides 19+ of
https://www.slideshare.net/arafalov/searching-for-ai-leveraging-solr-for-classic-artificial-intelligence-tasks

Regards,
   Alex.

On Fri, 5 Feb 2021 at 14:31, Hullegård, Jimi
<jimi.hulleg...@svensktnaringsliv.se> wrote:
>
> Ah, I never thought about grouping on date ranges, and nesting the faceting 
> like that. Interesting! I managed to do a quick test query that seems to give 
> me what I want:
>
> {
>     "query": "*:*",
>     "filter": "+category:* +modified:[NOW/DAY-60DAYS TO *]",
>     "limit": 0,
>     "facet": {
>         "ranges": {
>             "type": "range",
>             "field": "modified",
>             "start": "NOW/DAY-60DAYS",
>             "end": "NOW/DAY",
>             "gap": "+7DAY",
>             "sort": "index",
>             "facet": {
>                 "categories": {
>                     "type": "terms",
>                     "field": "category",
>                     "limit": -1
>                 }
>             }
>         }
>     }
> }
>
>
> But... this query, as well as all the examples, are in json query format, in 
> a request body. The actual query will be sent using a custom API that only 
> accepts a regular URL query, with parameters. Any idea how I can rewrite the 
> json query above into a URL query?
>
> Also, it would be easier to use the result if the ranges were sorted by the 
> date in descending order, but no matter what I tried I couldn't get it to 
> work. I thought that "sort": "index desc" should do the trick, but it seems 
> that index sort can't be reversed?
>
>
> Alexandre Rafalovitch wrote:
> >
> > This feels like basic faceting on category, but you are trying to make a 
> > latest record, rather than count as a sorting/grouping principle.
> >
> > How about using JSON Facets?
> >
> > https://lucene.apache.org/solr/guide/8_8/json-facet-api.html
> >
> > I would do the first level as range facet and do your dates at whatever 
> > granularity (say 1 week?) and then second level category terms.
> >
> > Let us know if it works. It is an interesting question.
> >
> Svenskt Näringsliv är företagsamhetens röst i Sverige. Vi samverkar med 50 
> arbetsgivar- och branschorganisationer och är den gemensamma rösten för 60 
> 000 företag med nästan 2 miljoner medarbetare. Vår uppgift är att tala för 
> alla företag och branscher, även de som ännu inte finns men som kan uppstå om 
> förutsättningarna är de rätta. Ett bättre företagsklimat för ett bättre 
> Sverige. Det är vårt uppdrag.
>
> Svenskt Näringsliv behandlar dina personuppgifter i enlighet med GDPR. Här 
> kan du läsa mer om vår behandling och dina rättigheter, 
> Integritetspolicy<https://www.svensktnaringsliv.se/dataskydd/integritet-och-behandling-av-personuppgifter_697219.html?utm_source=sn-email&utm_medium=email>

Reply via email to