OJAI Query Options

OJAI supports query options that enable you to modify the behavior of your queries. This includes an option to force secondary index usage and options to influence the behavior of sorts.

Available Query Options

The following table lists available query options. Some options may or may not apply, depending on whether your query uses the OJAI Distributed Query Service. The detailed descriptions make a note of this.

Option Name Description Details
ojai.mapr.query.hint-using-index Forces the MapR client to use a particular index, regardless of cost considerations Forcing Secondary Index Usage in OJAI
ojai.mapr.query.force-noncovering-sort Enables sort behavior to avoid partial sorts due to secondary index lags Avoiding Partial Sorts with Secondary Indexes in OJAI
ojai.mapr.query.max-client-sort-limit Sets the MapR client sort limit Comparisons and Sorts in OJAI Queries
ojai.mapr.query.force-drill When set to true, forces the MapR client to use the OJAI Distributed Query Service Forcing Usage of the OJAI Distributed Query Service
ojai.mapr.drill.<OJAI Distributed Query Service Property Name> Sets options for the OJAI Distributed Query Service Setting OJAI Distributed Query Service Properties

Setting Query Options

To set these options in your OJAI application, see the following topics:

Forcing Secondary Index Usage in OJAI

To force the MapR client to use an index, specify the name of the index with the ojai.mapr.query.hint-using-index option.

Regardless of cost considerations, the MapR client attempts to use the specified index. To use the index, the index must benefit filter conditions, the order by, or projections in the query as described at Queries that Benefit from Secondary Indexes. Otherwise, the MapR client ignores the option.

To force the MapR client to not use any indexes, specify the table name without the full path as the second parameter in the calls shown earlier. For example, if the full path of your table is /mapr/sanfrancisco/volume1/customer, pass the name customer as the second parameter.

Note: Setting this option in your OJAI application has no effect if you are using the OJAI Distributed Query Service.

Avoiding Partial Sorts with Secondary Indexes in OJAI

Partial sorts can occur due to secondary index lags. To avoid these lags, set the ojai.mapr.query.force-noncovering-sort option to TRUE.

This option forces the OJAI Distributed Query Service to explicitly sort the data. Do not set this option if you do not expect to encounter index lags. Otherwise, you lose the ordering advantage that secondary indexes provide.

For more information about why partial sorts occur, see Partial Sorts with Non-Covering Indexes.

Forcing Usage of the OJAI Distributed Query Service

When set to true, the MapR client uses the OJAI Distributed Query Service execution path, rather than selecting an execution path that it determines to be most optimal. See OJAI Distributed Query Service for more information about the different query execution paths.

Setting OJAI Distributed Query Service Properties

OJAI queries may leverage the OJAI Distributed Query Service. To modify OJAI Distributed Query Service property settings in your OJAI application, prefix the OJAI Distributed Query Service property name with ojai.mapr.drill.

For example, the option ojai.mapr.drill.planner.enable_index_planning disables using secondary indexes when queries use the Query Service.

See Index Planning and Execution Configuration Options for the list of available OJAI Distributed Query Service properties.