Custom Sorters
-
The Lucene indexing engine allows you to create your own Custom Sorters
where you can define how query results will be ordered based on your specific requirements. -
Custom sorters can be defined either at:
- the database level, where they can only be used with queries on that database
- or at the server-wide level, where they can be used with queries made on all databases in your cluster.
-
If a database custom sorter and a server-wide custom sorter share the same name,
the database custom sorter will be the one used for the query. -
This view lists all custom sorters that were uploaded via the Studio and from the client API.
-
Once deployed, you can order your query results using the custom sorter.
A query example is available here.
Database custom sorter view
Figure 1. Database custom sorter view
-
Navigate to Settings > Custom Sorters.
-
Click to add a new database custom sorter.
See the sorter edit view below. -
The custom sorters deployed for this database are listed here.
-
Click to test this custom sorter.
See the test view below. -
Click to edit this custom sorter.
-
Delete the custom sorter.
-
The custom sorters deployed server-wide are listed here.
-
Follow this link to manage the server-wide custom sorters.
Server-wide custom sorter view
Figure 2. Server-wide custom sorter view
-
Navigate to Manage Server > Server-Wide Sorters.
-
Click to add a new server-wide custom sorter.
See the sorter edit view below. -
The custom sorters deployed server-wide are listed here.
-
Click to edit this server-wide custom sorter.
-
Delete this server-wide custom sorter.
Note:
To test a server-wide sorter go to the Custom Sorters View in any database.
Add a custom sorter
Figure 3. Add a custom sorter
-
Either load the sorter's code from a
*.cs
file or enter the code manually in this editor. -
The sorter name must be the same as the class name of your sorter.
-
Replace the sample code in the image with your own implementation.
The sorter code must be compilable and include all necessaryusing
statements.
The sorter's class should inherit from Lucene.Net.Search.FieldComparator. -
Save your sorter.
Test the custom sorter
Figure 3. Test the custom sorter
-
Click to open the test view.
-
Enter an RQL query to test.
To order by your sorter useorder by custom(<field name>, <your sorter name>)
-
Click Run test.