
JSON and DSE Search
JSON is a popular format. This post provides information on easy ways to use JSON with DSE Search.
Some approaches to using JSON with DSE Search use FIT (Field Input Transformers) and other complex methods. These methods are valid, but there are easier ways of doing things which cover most cases. This demo uses DSE 5.0.3. Let’s see an example:
Set-up for the demo
1. Start by creating a CQL table:
|
2. Now create a DSE Search core against that table
|
Inserting JSON
A. Simple JSON String: Notice how we can feed our JSON directly to Apache Cassandra™ and DSE picks it up and indexes it. No need to do any preprocessing or exploding of the JSON string
|
B. Tuple JSON-like approach: When working with a Tuple or a UDT you can insert them with a JSON-like approach and keep the rest of the fields like in standard CQL statements. This approach is useful when the rest of the row fields, besides Tuple/UDTs, are not available in JSON.
|
C. Full JSON: Tuple/UDTS can be inserted if all your fields are available as JSON.
|
Querying for JSON
It is equally easy to get your results back as JSON.
|
Conclusions
There is no need to use FIT and other elaborate techniques to use JSON in DSE. Complex approaches like having a field holding the full JSON string, to be later exploded into individual fields so they are each indexed etc are not necessary. DSE provides out of the box functionality that supports JSON in most cases.