Filtering queries with the solr_query q format
Filter a CQL query using solr_query
option using the syntax of the Solr q parameter in plain text.
See Filtering on terms for examples.
solr_query = '<q_expression>'
Examples
Filtering on a single column
To find rows in the pets table where the name
column contains cat
, dog
but not fish
:
SELECT * FROM pets WHERE solr_query='name: cat name: dog -name:fish';
To use punctuation such as a single quote in the Solr q expression, see Escaping characters in a solr_query. |
Limiting results
When you name specific columns, DSE Search retrieves only the specified columns and returns the columns as part of the resulting rows.
DSE Search supports projections (SELECT a, b, c…) only, not functions, for the select expression.
The following example retrieves only the name
column:
SELECT name FROM keyspace.table WHERE solr_query='name:cat name:dog -name:fish'
Use the LIMIT clause to specify how many rows to return. The following example retrieves only 1 row:
SELECT * FROM keyspace.table WHERE solr_query='name:cat name:dog -name:fish' LIMIT 1
Using the count function
Use the count() function in CQL Solr queries to return the number of rows that satisfy the Solr query:
SELECT count(*) FROM table WHERE solr_query = '...';
Using count() in combination with LIMIT or facets results in an error.
All response queries of the drivers have a custom payload where the total number of documents found is returned.
This number is keyed as DSESearch.numFound
.