Solr Streaming Expression

64 Views Asked by At

I want to get total number of documents returned in Solr streaming expression. This document are result of grouping done by rollup over a particular field.

example,


rollup(
  search(
    test,
    q="*:*",
    qt="/export",
    fl="name,gender,city,id,birth_year",
    sort="name asc",
  ),
  over="birth_year",
  count(*)
)

I want total count returned for above expression. How can I achieve this with Solr 8.x

Also How I can do pagination on this?

Thanks!

This code I've tried


rollup(
  search(
    test,
    q="*:*",
    qt="/export",
    fl="name,gender,city,id,birth_year",
    sort="name asc",
  ),
  over="birth_year",
  count(*)
)

  • No help in getting the total count of grouped results
  • can't do pagination as export handler returns all results ever if we try to do it with start and rows.
1

There are 1 best solutions below

0
JD Patil On

I achieved this with the help of let

let(GroupedResults=rollup(
    search(
      customers,
      q="*:*",
      qt="/export",
      fl="gender_s,birth_year_s,customer_id_s,customer_first_name_s,customer_id_s",
      sort="customer_id_s asc"
    ),
    over="birth_year_s",
    sum(customer_id_s),
    count(*)
  ),
  b=col(GroupedResults, "customer_first_name_s"),
  TotalCount=length(b),
  echo="GroupedResults,TotalCount"
)