Solr - how to sort based on subquery

Viewed 789

I have question about Solr 7.0.0 and doing sort operations in combination with [subquery]:

I have two collections:

  • Collection A: for static data
  • Collection B: for data that is frequently updated, it has the same ID's as collection B.

The results of both collections i combine via fl=*,foo:[subquery]. The resulting response looks something like this:

  {
    "twda_names":["TWA"],
    "id":"TWA-2017-000",
    "file_loc":["Other"],
    "file_name":["Other"],
    "file_type":["Other"],
    "doc_type":["Other"],
    "_version_":1583236633578176512,
    "twda_names_str":["TWA"],
    "foo":[
      {
        "views":21,
        "id":"TWA-2017-000",
        "_version_":1583236633716588544}]},
  {
    "id":"TWA-2017-001",
    "twda_names":["TWRWRW"],
    "file_loc":["Other"],
    "file_name":["Other"],
    "file_type":["Other"],
    "doc_type":["Other"],
    "_version_":1583237084210003968,
    "twda_names_str":["TWRWRW"],
    "foo":[
      {
        "id":"TWA-2017-001",
        "views":99,
        "_version_":1583237084347367424}]}]

Now i would like to sort based on the field views, but cant seem to get it working..

What i have tried so far:

  1. &sort=faa:[subquery]asc and specifying &faa.q etc .... results in a error
  2. &sort=childfield(views) ... error
  3. &sort={!func}query($qq) and specifing &qq={!dismax qf=id} etc ... error

Any suggestions are much appreciated!

Thanks, Tim

1 Answers
Related