简体   繁体   English

Solr:在多值字段中使用查询参数进行排序

[英]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.如果我按 date_dateM asc 排序,我得到的是 Doc 1,因为它有 2023-01-31。

I can just use query and have no opinion to extend solr configuration.我只能使用查询,没有意见扩展 solr 配置。

User searching from [2023-02-06 TO *], so both docs are in result set.用户从 [2023-02-06 TO *] 搜索,所以两个文档都在结果集中。 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).所以首先应该是 Doc 2,因为它有一个 06.02,然后是 Doc 1 (07.02)。

Is it possible in solr? solr可以吗? Or is it possible to reduce date_dateM values to > 2023-02-06 and sort after that, for example as second query?或者是否可以将 date_dateM 值减少到 > 2023-02-06 并在之后排序,例如作为第二个查询?

For the time being, you can not sort by results in select range.目前,您无法按 select 范围内的结果进行排序。

As far as I can see, Solr considers only the min or max value when you sort by a multi-value field.据我所知,当您按多值字段排序时,Solr 仅考虑最小值或最大值。
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/默认情况下,Solr 获取最小值,但您也可以指定获取最大值: 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM