Identifying the partition key

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.


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. For example, with this table:

CREATE TABLE vtbl (k1 text, k2 text, valuetext, PRIMARYKEY ((k1, k2)))

Avoid using a query like this:

SELECT * FROM vtbl WHERE k1 = '50' AND solr_query='value:*'

Use a filter query against the partially specified composite partition key:

SELECT * FROM valuetable WHERE solr_query='{"q":"value:*", "fq":"k1:50"}'

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.

Using the Solr token function is for advanced users only and is supported only in specific use cases.


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.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000,