Search code examples
jsonpostsolr

Solr: Group via JSON request via HTTP POST


I am trying to use Solr's result grouping by posting JSON formatted query to the /query request handler (e.g. via the Documents tab in Solr's admin UI; use set request handler to /query)

The query is simple:

{
  "query":"Description:keyword",
  "offset":0,
  "limit":20
}

All samples I found use HTTP GET, e.g.:

http://localhost:8983/solr/techproducts/select?wt=json&indent=true&fl=id,name&q=solr+memory&group=true&group.field=manu_exact

When I try to add JSON field group, groups, grouping or something, the error message is always the same:

Unknown top-level key in JSON request : group...

I am aware of the approach provided here: POST json request to Solr with cursorMark in request (post url-encoded data instead of JSON). However, I'd like to avoid that. Any ideas how it can be done?


Solution

  • What I am looking for is the JSON Request API. Unfortunately, it seems that it is discontinued. In October 2016 Yonik wrote: "The JSON Request API is currently in it’s infancy – only a few query parameters are supported". The latest official documentation about the API is from 2015: https://cwiki.apache.org/confluence/display/solr/JSON+Request+API (and was also created by someone called Yonik. Coincidence?!) But it is not mentioned in the current reference guides Apache Solr 6.5/6.6.

    So the answer is: Result grouping cannot be accessed via a JSON query. Note: Same is true for the more current Collapse and Expand components.