Querying CQL collections
DSE Search supports CQL collections. In this example, you create a table containing a CQL set collection of famous quotations.
Procedure
-
Start DataStax Enterprise as a DSE Search node.
-
Start
cqlsh. -
Create a keyspace and a table for a collection column and other columns, and then insert data.
CREATE KEYSPACE mykeyspace WITH REPLICATION = {'class':'NetworkTopologyStrategy', 'Solr':1}; USE mykeyspace; CREATE TABLE mysolr ( id text PRIMARY KEY, name text, title text, quotes set text ); -
Download the
quotations.zipfile. -
Extract the
quotations.zipfile, copy the insert commands, and paste each command on thecqlshcommand line. -
Run the following command, which is located in the bin directory of tarball installations. For example, from a tarball installation:
installation_location/bin/dsetool create_core mykeyspace.mysolr generateResources=true reindex=trueIf you are recreating the
mykeyspace.mysolrcore, use thereload_corecommand instead of thecreate_corecommand.There is no output from this command. You can search data after indexing finishes.
-
In
cqlsh, search the indexed data to find quotes likesucc*.SELECT * FROM mykeyspace.mysolr WHERE solr_query='quotes:succ*';Because you created the core using automatically generated resources, the search index config defines the request handler for using CQL for search queries.
-
Using a browser, search-indexed data using the Solr HTTP API to find titles like
succ*.http://localhost:8983/solr/mykeyspace.mysolr/ select?q=quotes%3Asucc*&wt=json&indent=on&omitHeader=on{ "response":{"numFound":2,"start":0,"docs":[ { "id":"126", "title":"Success", "quotes":["If A is success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."], "name":"Albert Einstein"}, { "id":"125", "title":"Success", "quotes":["Always bear in mind that your own resolution to succeed is more important than any one thing.", "Better to remain silent and be thought a fool than to speak out and remove all doubt."], "name":"Abraham Lincoln"}] }}