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

Figure 1. Database custom sorter view

  1. Navigate to Settings > Custom Sorters.

  2. Click to add a new database custom sorter.
    See the sorter edit view below.

  3. The custom sorters deployed for this database are listed here.

  4. Click to test this custom sorter.
    See the test view below.

  5. Click to edit this custom sorter.

  6. Delete the custom sorter.

  7. The custom sorters deployed server-wide are listed here.

  8. Follow this link to manage the server-wide custom sorters.

Server-wide custom sorter view

Figure 2. Server-wide custom sorter view

Figure 2. Server-wide custom sorter view

  1. Navigate to Manage Server > Server-Wide Sorters.

  2. Click to add a new server-wide custom sorter.
    See the sorter edit view below.

  3. The custom sorters deployed server-wide are listed here.

  4. Click to edit this server-wide custom sorter.

  5. 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

Figure 3. Add a custom sorter

  1. Either load the sorter's code from a *.cs file or enter the code manually in this editor.

  2. The sorter name must be the same as the class name of your sorter.

  3. Replace the sample code in the image with your own implementation.
    The sorter code must be compilable and include all necessary using statements.
    The sorter's class should inherit from Lucene.Net.Search.FieldComparator.

  4. Save your sorter.

Test the custom sorter

Figure 4. Test the custom sorter

Figure 3. Test the custom sorter

  1. Click to open the test view.

  2. Enter an RQL query to test.
    To order by your sorter use order by custom(<field name>, <your sorter name>)

  3. Click Run test.