Comparisons and Sorts in OJAI Queries

When running OJAI queries with comparisons and sorts, you need to be aware of how different data types behave. You also need to understand how sorting works in MapR-DB queries. Depending on the component that runs the sort, you may encounter unexpected behavior.

OJAI supports comparisons using the QueryCondition interface. For information about how to use this interface, see Query Conditions in OJAI Applications.

When using the OJAI Query where and orderby, and comparing and sorting across different data types, there are subtleties you should take into consideration. See Using Comparable JSON Document Data Types in Comparisons and Sorts and Using Non-comparable JSON Document Data Types in Comparisons and Sorts for more information.

If you do not have a secondary index defined that can generate your query's specified orderby, then your query requires an explicit sort. If you have installed the OJAI Distributed Query Service, the service performs the sort. If you have not, the MapR client performs the sort, but restricts the amount of data it can sort. The default sort limit is 5000 documents. For example, if your query returns 10,000 documents, and you specify a query result limit of 5000 documents, the MapR client can perform the sort.

Important: The MapR client returns an error if your query result size exceeds the client's sort limit.

You can avoid errors due to the client sort limitation by adhering to the following guidelines: