Identifying the partition key

Restrictions and guidelines for filtering results by partition key when also using a Solr query.

Solr CQL queries support restriction to a single partition key. Partition key restrictions work only when _partitionKey is explicitly indexed or the schema explicitly includes all of the components of the database partition key. In your schema, you can override _partitionKey when not using joins.

Example:
SELECT id, date, value FROM keyspace.table WHERE id = 'series1' AND solr_query='value:bar*';
CQL partition key restrictions work only with fully specified partition keys.
CREATE TABLE vtbl (k1 text, k2 text, value text, PRIMARY KEY (k1, k2));
For example, with the above table, avoid using a query such as shown below:
SELECT * FROM vtbl WHERE k1 = '50' AND solr_query='value:*'
Use a filter query against the partially specified composite partition key, "fq":"k1:50":
SELECT * FROM valuetable WHERE solr_query='{"q":"value:*", "fq":"k1:50"}'

Restricting nodes queried using the Solr token function

Solr CQL queries support limited use of the token function. The token function enables targeted search that restricts the nodes queried to reduce latency.
Note: Using the Solr token function is for advanced users only and is supported only in specific use cases.
Example:
SELECT id, value FROM keyspace.table WHERE token(id) >= -3074457345618258601 AND token(id) <= 3074457345618258603 AND solr_query='id:*'
Example with an open range:
SELECT id, value FROM keyspace.table WHERE token(id) >= 3074457345618258604 AND solr_query='id:*'
Constraints apply to using the token function with Solr CQL queries:
  • token() cannot be used with route.range or route.partition
  • Wrapping token() ranges are not supported
  • A specified token() range must be owned by a single node; ranges cannot span multiple nodes
  • Because DSE uses the Solr single-pass queries, only the fields that are declared in the search schema are returned in the query results. If you have columns that do not need to be indexed but still need to be returned by using a token-restricted query, you can declare the columns as stored non-indexed fields in your schema.xml file.

Overriding _partitionKey when not using joins

The special _partitionKey field is used internally for joins. If you do not plan on using joins, you can override this field declaration in the schema.xml file for only the indexed and docValues properties.

To prevent the _partitionKey field from being indexed, set indexed to false:
<field name="_partitionKey" type="string" indexed="false"/>
To prevent building docValues for the _partitionKey field, set docValues to false:
<field name="_partitionKey" type="string" docValues="false"/>