sortingsolrmultivalue

Solr: Use query params in sort in multivalued field


I have a field with dates:

Doc 1:
"date_dateM":["2023-01-31T00:00:00Z",
          "2023-02-07T00:00:00Z",
          "2023-02-14T00:00:00Z",
          "2023-02-21T00:00:00Z"],
Doc 2:
"date_dateM":["2023-01-16T00:00:00Z",
          "2023-01-23T00:00:00Z",
          "2023-01-30T00:00:00Z",
          "2023-02-06T00:00:00Z",
          "2023-02-13T00:00:00Z",
          "2023-02-20T00:00:00Z",
          "2023-02-27T00:00:00Z"],

If I sort by date_dateM asc, i've got Doc 1, because it has 2023-01-31.

I can just use query and have no opinion to extend solr configuration.

User searching from [2023-02-06 TO *], so both docs are in result set. I want to sort result in search range. So first should came Doc 2, because it has a 06.02 and after that Doc 1 (07.02).

Is it possible in solr? Or is it possible to reduce date_dateM values to > 2023-02-06 and sort after that, for example as second query?


Solution

  • For the time being, you can not sort by results in select range.

    As far as I can see, Solr considers only the min or max value when you sort by a multi-value field.
    By default, Solr gets the min values but you can also specify to get the max value: https://lucidworks.com/post/minmax-on-multivalued-field/

    Example:

    http://localhost:8983/solr/collection_name/select?indent=true&q.op=OR&q=date_dateM:[2023-01-31T00:00:00.000Z TO *]&sort=field(date_dateM,max) asc