Solr中的条件排序

时间:2016-10-05 23:19:00

标签: solr lucene

我们希望按import java.util.Scanner; //Needed for Scanner class. public class PayrollTest { public static void main(String[] args) { String EmployeeName; int IDnumber; double HoursWorked; double HourlyPayRate; double GrossPay; //Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); //Get the employee's name. System.out.println("Enter an employee's name: "); EmployeeName = keyboard.nextLine(); //Get the employee's ID. System.out.println("Enter the employee's ID " ); IDnumber = keyboard.nextInt(); //Get the number of hours worked by the employee. System.out.println("Enter the amount of hours worked by this employee: "); HoursWorked = keyboard.nextDouble(); //Get the hourly pay rate of the employee. System.out.println("Enter the hourly pay rate for this employee: "); HourlyPayRate = keyboard.nextDouble(); //Create a payroll object, passing EmployeeName and IDnumber // as arguments to the constructor. Payroll pay = new Payroll(EmployeeName, IDnumber); //Get the Gross Pay of the employee. System.out.println("The gross pay of " + EmployeeName + " is: " + pay.getGrossPay()); } }

排序

代表:total- count

此外,我们希望按日期排序,以防在排序时有两个数字并列。

是否可以在Solr中执行此操作?

1 个答案:

答案 0 :(得分:3)

是的,这是可能的。 Solr允许通过函数的输出对结果进行排序,因此您可以使用sub() total 中减去 count 。它还支持多种排序,您可以提供以逗号分隔的排序条件列表。

  

排序顺序必须包含字段名称(或分数为伪   字段),后跟空格(在URL字符串中转义为+或%20),   然后是排序方向。

在您的情况下,您可以执行以下操作:

sort=sub(Total_ix, count_ix) desc, date desc

比照The sort parameterFunction Queries